Can someone interpret this entry in my htaccess file into english so that I can understand?
-
There are a number of entries in my htaccess and I'd like to understand what they are doing so that I can understand if they need to be there or not.
So, can someone tell me what this says...in plain english?
RewriteCond %{HTTP_HOST} ^legacytravel.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.legacytravel.com$
RewriteRule ^carrollton-travel-agent$ "http://www.legacytravel.com/carrollton-travel-agent" [R=301,L]Thank you a million times in advance.
-
Hello, my old htaccess buddy!
Let's say, perhaps, that a person wanted to change her main company blog from www.legacytravel.com/ramblings to www.legacytravel.com/blog.
Of course, all of the traffic would need to be re-directed. the htaccess currently says:
BEGIN WordPress
<ifmodule mod_rewrite.c="">RewriteEngine On
RewriteBase /ramblings/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /ramblings/index.php [L]</ifmodule>END WordPress
Would it be appropriate / effective to add something there that directs everything in light of the renaming of that subfolder?
Again, thank you in advance.
-
Yep. Of course, as with any change, back the old rules up into a text file before making the move... just in case it explodes everything (but it won't). Just a precaution.
-
Alright, so if I take out all of the other nonsense...and just put this in...will that just make it go from legacytravel.com to www.legacytravel.com?
and that's that?
-
Sorry to disappoint, Travis. Nothing too complicated, looks like it was just a botched www cleanup. A good old:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^legacytravel.com [NC]
RewriteRule ^(.*)$ http://www.legacytravel.com/$1 [L,R=301]Will do the trick.
-
It doesn't force www in any instance. That's why I'm looking forward to the solution.
-
Hi,
That line of htaccess says:
If the host is legacytravel.com OR www.legacytravel.com, then lets try this rule below.
One conditions will always be true since the htaccess is on your site. So they cancel each other out, and are not needed.
The rule says if the URI matches the regular expression '^carrollton-travel-agent$' then redirect (r=301) to the target URL and stop processing rules (L flag for last)
Your RewriteRule target doesn't need characters escaping because it is not a regular expression, just a URL to redirect to. You also don't need the quotes, they're useful for grouping arguments with spaces in them but that's not affecting it.
Really this rewriterule doesn't accomplish anything, it redirects /carrollton-travel-agent to /carrollton-travel-agent, forcing the www. no matter which version is accessed. But if that is what you're wishing to achieve then there's a much simpler solution:
RewriteCond %{HTTP_HOST} !^www.legacytravel.com$ [NC]
RewriteRule ^(.*)$ http://www.legacytravel.com/$1 [R=301,L]
Notice we only use the \backslash to escape characters in regex patterns, and not in our target URL. What that rule will do is redirect any visitor where the host is missing the www to the equivalent page with the preceding www.
Hope that helps.
-
Would like to hear the resolution, given my endorsement.
-
Escaping characters isn't a big deal with newer version of Apache. No need for all those slashes, unless it's something more complex. From what I've seen, at least.
-
You got it.
Again, thank you so much for taking a look.
-
Alright... just give me a day or two since you don't have me on retainer
-
Alright...I just sent the whole redirect portion of the htaccess file to WilliamKammer.
Thank you so much, everyone, for your help.
-
I'm guessing you want to escape regex characters with a ? XD I just want to say again, that regex101 is a good resource. So thanks for sharing that.
-
I'm determined to master htaccess and regex... feel free to pm me the file
-
William may well be correct. I'm far from a Joomla! expert, I generally fix Joomla! problems by migrating to WordPress, so I don't know how that framework/CMS handles redirects. I'm not exactly criticizing Joomla!, but these things shouldn't be a problem. (Redirects are generally handled on the server level, I just don't know about Joomla!.)
This sounds like it's been around for a while, so it might not be a DNS issue, but keep that in your possible bucket.
Would you give one of us the entire .htaccess file via PM? I would prefer William, because he does these things for free all the time. Alternately, you can check it out yourself with http://htaccess.madewithlove.be/.
It's really funny though. I must have driven by your place a number of times. I used to live on Preston, about a mile away. It's Grapevine for me, these days. The place is a little more my speed.
-
It looks like the rule is attempting to rewrite www.legacytravel.com and legacytravel.com to legacytravel.com/carrollton-travel-agent, but it's not working. This is likely due to the piece on line 3 before the final URL (unless the person was attempting something else I'm not familiar with). Others issues could be the rewrite engine not being turned on, the .htaccess file being in the wrong place, or some other issue, like server settings.
-
The first two lines are the condition. It is saying if anyone comes to legacytravel.com or www.legacytravel.com then it is looking for this string carrollton-travel-agent if that string is found, then it will rewrite the url to http:\www.legacytravel.com/carrollton-travel-agent I don't really know why that rule is in place, but I am not familiar with the site.
You can learn about what the symbols in the htaccess mean here, http://perishablepress.com/stupid-htaccess-tricks/
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Can bad html code hurt your website from ranking ?
Hello,For example if I search for “ Bike Tours in France” I am looking for a page with a list of tours in France.Does it mean that if my html doesn’t have list * in the code but only that apparently doesn’t have any semantic meaning for a search engine my page won’t rank because of that ?Example on this page : https://bit.ly/2C6hGUn According to W3schools: "A semantic element clearly describes its meaning to both the browser and the developer. Examples of non-semantic elements: <div> and - Tells nothing about its content. Examples of semanticelements: <form>, , and- Clearly defines its content."Has anyone any experience with something similar ?Thank you, </form>
Technical SEO | | seoanalytics0 -
Can you use schema markup to do this?
We sell steel plates. They come in a number of different grades and then in a variety of sizes. Generally we have a page for each unique grade. What I want to do is to use schema to enhance the rich snippet in SERPS to say something like width: 2 - 3.5m length 6 - 14m thickness 6 - 300mm Phosphorous: 0.005% Sulphur 0.005% is this possible using schema? would I use thing/product or another theme? i'm trying to scope out the possibilities here to determine whether it is worth spending time on. The the other more interesting question is whether it is possible to respond differently to informational and purchasing searches. So if someone is looking for informations physical and chemical properties would be best used in the schema markup. If they are looking to purchase then product characteristics. Can these be shown differentially?
Technical SEO | | Zippy-Bungle0 -
Can Googlebot crawl the content on this page?
Hi all, I've read the posts in Google about Ajax and javascript (https://support.google.com/webmasters/answer/174992?hl=en) and also this post: http://moz.com/ugc/can-google-really-access-content-in-javascript-really. I am trying to evaluate if the content on this page, http://www.vwarcher.com/CustomerReviews, is crawlable by Googlebot? It appears not to be. I perused the sitemap and don't see any ugly Ajax URLs included as Google suggests doing. Also, the page is definitely indexed, but appears the content is only indexed via its original source (Yahoo!, Citysearch, Google+, etc.). I understand why they are using this dynamic content, because it looks nice to an end-user and requires little to no maintenance. But, is it providing them any SEO benefit? It appears to me that it would be far better to take these reviews and simply build them into HTML. Thoughts?
Technical SEO | | danatanseo0 -
Can I have an H1 tag below an H2?
Quick question for you all - Is there an issue with me having an H1 tag physically below an H2 tag on a web page??
Technical SEO | | Pete40 -
How can I block incoming links from a bad web site ?
Hello all, We got a new client recently who had a warning from Google Webmasters tools for manual soft penalty. I did a lot of search and I found out one particular site that sounds roughly 100k links to one page and has been potentialy a high risk site. I wish to block those links from coming in to my site but their webmaster is nowhere to be seen and I do not want to use the disavow tool. Is there a way I can use code to our htaccess file or any other method? Would appreciate anyone's immediate response. Kind Regards
Technical SEO | | artdivision0 -
Kill your htaccess file, take the risk to learn a little
Last week I was browsing Google's index with "site:www.mydomain.com and wanted to scan over to see what Google had indexed with my site. I came across a URL that was mistakenly indexed. It went something like this www.mydomain.com/link1/link2/link1/link4/link3 I didn't understand why Google had indexed a page like that of mine when the "link" pages were links that were on my main bar which were site wide links. It seemed to be looping infinitely over and over. So I started trying to see how many of these Google had indexed and I came across about 20 pages. I went through the process of removing the URL's in Webmaster Tools, but then I wanted to know why it was happening. I had discovered that I had mistakenly placed some links on my site in my header in such a manner link1 link2 link3 If you know HTML you will realize that by not placing the "/" in the front of the link I was telling that page to add that link in addition to the URL that is was currently on. What this did was create an infinite loop of links which is not good 🙂 Basically when Google went to www.mydomain.com/link1/ it found the other links which then told Google to add that url to the existing URL and then go to that link. Something like: www.mydomain.com/links1/link2/... When you do not add the "/" in front of the directory you are linking too it will do this. The "/" refers to the root so if you place that in front of your directory you are linking too it will always assume that first "/" as the root then the url will follow. So what did I do? Even though I was able to find about 20 URL's using the "site:" search method there had to be more out there. Even though I tried to search I was not able to find anymore, but I was not convinced. The light bulb went on at this point My .htaccess file contained many 301 redirects in my attempt to try and redirect those pages to a real page, they were not really relevant pages to redirect too. So how could I really find out what Google had indexed out there for me since Webmaster Tools only reports the top 1000 links. I decided to kill my htaccess file. Knowing that Google is "forgiving" when major changes to your site happen I knew Google would not simply just kill my site for removing my htaccess file immediately. I waited 3 days then BOOM! Webmaster Tools was reporting to me that it found a ton of 401's on my site. I looked at the Crawl Errors and there they were. All those infinite loop links that I knew had to be more out there, I was able to see. How many were there? Google found in the first crawl over 5,000 of them. OMG! Yeah could you imagine the "Low quality" score I was getting on those pages? By seeing all those links I was able to determine about 4 patterns in the links. For example: www.mydomain.com/link1/link2/ www.mydomain.com/link1/link3/ www.mydomain.com/link1/link4/ www.mydomain.com/link1/link5/ Now my issue was I wanted to keep all the URL's that were pointing to www.mydomain.com/link1 but anything after that I needed gone. I went into my Robots.txt file and added this Disallow: www.mydomain.com/link1/link2/ Disallow: www.mydomain.com/link1/link3/ Disallow: www.mydomain.com/link1/link4/ Disallow: www.mydomain.com/link1/link5/ Now there were many more pages indexed that went deeper into those links but I knew I wanted anything after the 2nd URL gone since it was the start of the loop that I detected. With that I was able to have from what I know at least 5k links if not more. What did I learn from this? Kill your htaccess file for a few days and see what comes back in your reports. You might learn something 🙂 After doing this I simply replaced my htaccess file and I am on my way to removing a ton of "low quality" links I didn't even know I had.
Technical SEO | | cbielich0 -
Can we use our existing site content on new site?
We added 1000s of pages unique content on our site and soon after google release penguin and we loose our ranking for major keywords and after months of efforts we decided to start a new site. If we use all the existing site content on new domain does google going to penalized the site for duplicate content or it will be treated as unique? Thanks
Technical SEO | | mozfreak0 -
Can Google read onClick links?
Can Google read and pass link juice in a link like this? <a <span="">href</a><a <span="">="#Link123" onClick="window.open('http://www.mycompany.com/example','Link123')">src="../../img/example.gif"/></a> Thanks!
Technical SEO | | jorgediaz0