Use Your .htaccess File to Redirect an Alternative Domain

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

Redirect for Success

If you purchase an alternative domain name, you need to have it redirect to the primary domain. This avoids duplicate content between the two. The search engine spiders will index each domain name separately and the content will be exactly the same. This is not a good scenario and this SEO fundamental must always be taken into account with multiple domains.

Using the .htaccess file, I’m going to show you how to redirect one domain to another.

Your website needs to be running on an Apache HTTP Server. Use this Server Header Checker Tool to find out what type of server your website is running on. You will also need to make sure the DNS of your alternative domain is pointed to the same web server as your primary domain.

Enter the following code at the top of your .htaccess file.

RewriteEngine on

# ---------------
RewriteCond %{HTTP_HOST} ^www.alternativedomain.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^alternativedomain.com$ [NC]
RewriteRule (.*) http://www.primarydomain.com/$1 [R=301,L]

The code above performs a 301 permanent redirect for all requests that are going to the alternative domain. This code is using the [OR] rule to account for both WWW and non-WWW. You can repeat the same code to redirect all of your alternative domains.

This technique can also be useful if you are going to switch to a new primary domain name. The 301 permanent redirect transfers the Google PageRank of the old primary domain to the new one.

Another important .htaccess rule that you should be using is redirecting your non-WWW version of your domain to the WWW version.

Add the following code below to make this happen.

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

With the following codes added to your .htaccess file, you can be rest assured that your domains will redirect correctly and promote strong SEO growth for your website.

If you run into any issues, PaperStreet clients can always reach the developers for additional assistance by emailing helpme@paperstreet.com.

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.

One Response to Use Your .htaccess File to Redirect an Alternative Domain

  1. Shelley
    1:07 pm on June 28th, 2017

    I tried this out, using the first htaccess code and it works when domain.com is searched. It doesn’t work when it is searched with the www. though? Then I added the second htaccess code to the file and still would not redirect the www?

    By the way I like this site. good info and clear.

Leave a Reply

Your email address will not be published. Required fields are marked *