.htaccess Redirects: www, non-www, and alternate domains

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

Why Redirect?

For SEO purposes and marketing purposes, you often want to have all your domains redirected into a primary domain. This helps with telling the search engines and your visitors your primary web site address. Your client may have 2, 5, 10 or 20 domains and they all should point to the primary www version, so how do you do all the redirects?”¬† Easy.

When you are doing .htaccess rewrites for alternate domains, there is a difference between redirecting the non-www primary domain to its www version, and redirecting both the www and non-www of alternate domains to the primary www version.

Steps to Redirect

A single redirect of non-www code to the www version is listed below. If you are redirecting an alternate domain, you need to actually redirect both the www and non-www version. You can use an OR statement to redirect both the non-www alternate domain and www-alternate domain to the primary www version.

Wow that is a mouthful, so let’s use some examples:

Ex: To redirect a domain.com into www.domain.com.

This is if a client only has one domain and you want to make sure that the www version is the primary domain.

RewriteCond %{HTTP_HOST} ^domain.com

RewriteRule ^(.*)$ http://www. domain.com/$1 [L,R=301]

Ex: ”¬†alternatedomain.com and www.alternatedomain redirected to www.domain.com.

Use this code to redirect an alternate domain (both non-www and www) version to the primary domain. You can use this code multiple times, for as many domains as needed (see attached). As you can see, you can use the [OR] clause to use both the www and non-www in one rewrite rule, basically two conditions and one rule. This will reduce code in your .htaccess file.

RewriteCond %{HTTP_HOST} ^www. domain.biz [OR]

RewriteCond %{HTTP_HOST} ^ domain.biz

RewriteRule ^(.*)$ http://www. domain.com/$1 [L,R=301]

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. Required fields are marked *