Use Your .htaccess File to Redirect an Alternative Domain

A white, rounded square logo with an abstract S-shaped design on a gradient blue and purple background.

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

#ALTERNATE DOMAINS
# ---------------
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.

Share This

Join the Sales and Marketing News, receive our last insights, tips and best practices.

Our 7 Guarantees

Keeping 2,000+ Clients Happy Since 2001.

1
You Will Love Your Design We design to please you and your clients
2
Same-Day Support 24-hour turnaround edits during business hours
3
Free Education We provide knowledge to help you expand
4
No Hidden Charges We quote flat-rate projects
5
Own Your Site No strings attached
6
We Create Results SEO, PPC, content + design = clients
7
We Make Life Easier One agency for web, branding and marketing