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 I still monitor noindex, nofollow pages with Google Analytics?
I have a private/login site where all pages are noindex, nofollow. Can I still monitor external site links with Google Analytics?
Technical SEO | | jasmine.silver0 -
Blocking subdomains with Robots.txt file
We noticed that Google is indexing our pre-production site ibweb.prod.interstatebatteries.com in addition to indexing our main site interstatebatteries.com. Can you all help shed some light on the proper way to no-index our pre-prod site without impacting our live site?
Technical SEO | | paulwatley0 -
CSS and Javascipt files - website redesign project
UPDATED: We ran a crawl of the old website and have a list of css and javascript links as are part of the old website content. As the website is redesigned from scratch, I don't think these old css and javascipt files are being used for anything on the new site. I've read elsewhere online that you redirect "all" content files if launching/migrating to a new site. We are debating if this is needed for css and javascript files. Examples (A) http://website.com/wp-content/themes/style.css (B) http://website.com/wp-includes/js/wp-embed.min.js?ver=4.8.1
Technical SEO | | CREW-MARKETING0 -
What can I do to stop ranking for a keyword that has nothing to do with the companies website?
A website that we maintain keeps ranking for the keyword 'homeless shelter'. The company is UTILIS USA and they produce heavy duty shelters for military personnel. They have nothing to do with homeless shelters but continue to receive traffic concerning the phrase.
Technical SEO | | ReviveMedia0 -
Can the Hosting location of image files have a negative effect if 'off-site' such as on the devs own media server ?
Hi Can the Hosting location of image files have a negative effect if 'off-site' such as if they are on the developers own media server ? As opposed to on the actual websites server or file structure ? In the case i'm looking at the image files are hosted on a totally separate server (a media subdomain of the developers site server) from the subject sites dedicated server. Will engines still attribute the properties of files hosted in this manner to the main website (such as file name, alt attributes, etc etc) ? Or should they really be on the subject sites server own media folder ? Cheers Dan
Technical SEO | | Dan-Lawrence0 -
Can you 301 redirect a page to an already existing/old page ?
If you delete a page (say a sub department/category page on an ecommerce store) should you 301 redirect its url to the nearest equivalent page still on the site or just delete and forget about it ? Generally should you try and 301 redirect any old pages your deleting if you can find suitable page with similar content to redirect to. Wont G consider it weird if you say a page has moved permenantly to such and such an address if that page/address existed before ? I presume its fine since say in the scenario of consolidating departments on your store you want to redirect the department page your going to delete to the existing pages/department you are consolidating old departments products into ?
Technical SEO | | Dan-Lawrence0 -
Can Google Anlaytics Segment By Time of the DaY?
Greetings from Latitude 53.92705600 Longitude -1.38481600... Can Google analytics anser this question..."Tell me on the 1st Sept how many visitors landed on my site between 1200HRS & 1300HRS" Grazie Tanto,
Technical SEO | | Nightwing
David0 -
Why does our page show a description in english in google spain?
Hi! We have a multilingual page and I have set in Google Webmaster Tools the language preference for the root domain to be none, Spanish for the .com/es, English for the .com/en, and German for the .com/de. The title and description show in the right language in Google Germany and google UK, but in google.es (Spain) the title and description appear in English instead of Spanish. Does anybody know why could this be happening and how to fix it? kJtF3.png
Technical SEO | | inmonova0