divider

.htaccess: .co domains and redirects

Services: Law Firm Website Design . SEO . Internet Marketing . Law Firm Marketing Guide . Content Marketing . PPC

When doing multiple htaccess redirects, there is an issue with .co domains conflicting with .com redirects. If you already have a non-www version of your .com domain redirecting into the www version of the .com domain, then any www .co domain redirect into the www .com will cause a failure.

To solve this, you need to put in a $ at the end of a www .co redirect (and sometimes in the non-www too). Otherwise if you leave out the $, you end up creating an infinite loop of redirecting the www.domain.com into www.domain.com (or at least the htaccess thinks you are trying to do that). This crashes all the redirects of the entire site.

The $ signifies end of the expression and stops this from happening as it signifies that you are only trying to redirect .co and not .com. So if you ever end up with a crash situation with multiple similar domain extensions, use the $ at the end of a line. Here is the code to use:

RewriteCond %{HTTP_HOST} ^ domain.co [OR]
RewriteCond %{HTTP_HOST} ^www. domain.co$
RewriteRule ^(.*)$ http://www. domain.com/$1 [L,R=301]

* I have made the $ red to denote the code. Obviously, you do not need to make yours red in your htaccess file (not that you could, if you tried).


Related Posts

Ready to Take Your Website to the Next Level? Great Ideas & Results Only a Phone Call Away

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Let's get started.

Leave a Reply

Your email address will not be published.

*