Forum Moderators: phranque

Message Too Old, No Replies

301 redirect using .htaccess

301, re-direct, htaccess, apache, site new address

         

bornlsr

5:12 pm on Jun 12, 2010 (gmt 0)

10+ Year Member



Hi,

Recently I have moved my site from a old domain name to a new domain name.

I have followed Google's Webmaster guidelines, and modified .htaccess accordingly.

The transfer is perfect.

I just wanted to know that as the only important file in my old domain hosting is the .htaccess file, can I delete the database and all other files from my old hosting account, and just keep the .htaccess file, till Google re-indexes my new site ?

g1smd

5:36 pm on Jun 12, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes, if requesting the old domain at the old hosting simply results in a redirect to the new domain at the new hosting then you can remove all files from the old host.

However, you can go further.

Install the old domain to new domain .htaccess redirect on the new host, and set it so that it only redirects requests for the old domain to the new domain. Point the DNS for the old domain name to the new server. Wait for the DNS to update and then stop paying for the extra hosting that you do not need.

bornlsr

5:50 am on Jun 13, 2010 (gmt 0)

10+ Year Member



Thanks a lot g1smd. I was wondering that I would have to keep on paying for two hosting each month for at least 6 months.

But still I have a little bit of confusion. Can a domain be re-directed to another, without having a hosting space ?

If I am not wrong, what you are suggesting is applying the DNS settings of my new domain to old domain as well, so that both the domains point to the same IP address.

If this is the case, is it legal ?
Is it inline with Google's policies ?

Thanks in advance

g1smd

6:53 am on Jun 13, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes. Point all the domains at the one hosting space.

Ordinarily this would result in Duplicate Content as
/page-one.html
could be accessed by
(www.)example.com/page-one.html
and by
(www.)example.co.uk/page-one.html
and you want to avoid that.

So, you install this code in the
.htaccess
file on the server:

# Redirect all requests for any hostname other than
# exactly "www.example.com" to "www.example.com".
# Preserve all path and query string data in the redirect.
RewriteCond %{HTTP_HOST} !^(www\.example.\com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]


Now all requests for any page at
example.co.uk
or
www.example.co.uk
or
example.com
are redirected to the same page at
www.example.com
instead.

There are no legal issues (as long as you own both domains), and this stuff is highly recommended by all search engines.

jdMorgan

12:49 am on Jun 15, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's also good because you need to leave this Old-domain-to-New-domain redirect in place for (probably) *years* -- or until you no longer need the referrals or 'link juice' from the links to the old domain. A 301 redirect only has meaning for as long as it can be invoked, so this is *not* a matter of "leaving the .htaccess in place until the site gets re-indexed." It is a matter of leaving the redirect in place until the old links not longer matter... and that could be a long, long time.

Som pointing the old domain's DNS to the new server, and putting the above code in place is the most effective and least expensive way to maintain the 301 redirects.

Jim