Computer Programming web Web programming Tips



How to use multiple domains
for one web site. 301 Redirect

By Sergey Skudaev


On this page I will show you different methods for 301- Redirect. The 301 redirect allows redirecting visitors from one URL to the other URL. Why we would need it? We may have few different reasons for redirection. One of them is using few domain names for the same web site. It is possible to use few domains for one web site. However, It is important not to create a condition, when the same page can be accessed by more that one URL. If the same site can be accessed by two or more URL, then Google will consider the site accessible through one domain as a duplicate of the site accessible through the other domain. To avoid such situation you can use 301 Redirect.

Let me explain you how I solved this problem for my web site. First, I registered few domains for the same site: new-trip.com, best-your-trip.com, trip-dreams.com and wish-trip.com. My primary domain is best-your-trip.com. In my host control panel I found Addon Domains icon.

Host control panel - Addon domain icon

I clicked it, and added wish-trip.com domain as Addon domains.

Create Addon domain

After that, I clicked Redirects icon and redirected trip-dreams.com Addon domain to the primary domain. Then I added the trip-dreams.com domain as Addon domain and in the same way, I redirected it to the primary domain.

301 Redirect Addon domains

Now both Addon domains are redirected to the primary domain.

My new-trip.com domain was added as Addon domain to my different host with the primary domain learn-coding.today.

To redirect new-trip.com to the best-your-trip.com domain, I used the following script in .htaccess file, which is located in my root directory for the new-trip.com domain.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^new-trip.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.new-trip.com$
RewriteRule ^(.*)$ "http\:\/\/www\.best\-your\-trip\.com$1" [R=301,L]





Now all three my Addon domains: trip-dreams.com, wish-trip.com and new-trip.com are redirected to the primary domain: best-your-trip.com.

I had one more problem. I had a web page with photos of the Honeymoon Island Park on a web site with the primary domain name "serge-world.com". I moved this web page with the Honeymoon photos to the web site with best-your-trip.com domain. But in google search index my old URL to the honeymoon.php page still exists.

Now I had to redirect the http://www.serge-world.com/honeymoon.php page to the http://www.best-your-trip.com/honeymoon.php.

In the .htaccess file, which is located in my root directory for the serge-world.com, I typed the following script:

Redirect 301 /honeymoon.php http://www.best-your-trip.com/honeymoon.php

Now, if a user finds an old URL in Google search, he will be redirected to the new page location.

Besides, I redirected all my domains without www to domains with www, using the following script in the .htaccess file.

RewriteEngine on RewriteCond %{HTTP_HOST} ^learn-coding.today$ RewriteRule ^/?$ "http\:\/\/www\.learn\-coding\.com" [R=301,L]


My eBooks on Amazon.com

US    UK    BR    CA
US   UK   BR   CA
US    UK    BR    CA