Welcome to WebmasterWorld Guest from 54.226.147.190

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

.htaccess / 301 redirect an entire site to new domain

.htaccess / 301 redirect an entire site to new domain

     

g1tech

8:22 pm on Feb 4, 2007 (gmt 0)

5+ Year Member



Longtime lurker, first post..

Forgive me if this has been addressed, I see many topics on 301 redirects, but none addressing a situation where someone moves an entire site to a new domain..

Has anyone successfully moved a site to a new domain, redirected traffic coming into the old domain's pages to the corresponding page on the new domain, while preserving their search engine rankings?

The old domain is hosted on a Linux server and we do have access to the .htaccess file. Can anyone direct me to a discussion or article about this?

Any help is greatly appreciated!

jdMorgan

8:59 pm on Feb 4, 2007 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Hi g1tech,

Welcome to WebmasterWorld!

This search [google.com] should help you to get started.

Jim

g1tech

9:11 pm on Feb 4, 2007 (gmt 0)

5+ Year Member



Thank you, I've looked through those but I guess I just need to know if there is any code to redirect all traffic coming to the old domain, to the new domain's corresponding page. Like:

[olddomain.com...]
gets redirected to: [newdomain...]

If there is some code or script that can used to do this for all pages, without having to make an entry for each individual page in the .htaccess file, this would be what I'm after.

From everything I've read, there is no shortcut, but thought I'd check with you guys to be sure before I type out almost 1000 entries in our .htaccess file :)

jdMorgan

10:53 pm on Feb 4, 2007 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



If you'd read the Redirect [httpd.apache.org] documentation in Apache mod_alias (linked from several of those threads), you'd have found that you can do the whole domain with a single directive:

Redirect 301 / http://www.example.com/

That's it.

Jim

g1tech

6:26 am on Feb 5, 2007 (gmt 0)

5+ Year Member



I ended up using this code in my .htaccess file:

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) [newdomain.com...] [R=301,L]

And it works just the way it should :)

I assume that this is equivalent to the above suggestion...

g1tech

1:23 am on Feb 17, 2007 (gmt 0)

5+ Year Member



I thought I'd update this thread with the results of my 301 redirect for further discussion. The redirects work flawlessly so any visitors clicking back on bookmarked links and/or finding our old URL's in the search engines are finding the correct pages.

However, in the 2 weeks that we've had the 301 redirect in place, our olddomain.com URLs have fallen to 2nd and 3rd pages (sometimes lower) in Google on searches that we previously appeared at or near the top. These old URLs haven't yet been replaced with the newdomain.com URLs that we are redirecting the olddomain.com traffic to. Our 'free traffic' is down sharply during this time.

Is this normal? Has anyone else that has changed website domains experienced something similar?

Thanks,
g1tech

jdMorgan

3:42 pm on Feb 19, 2007 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



It may take up to 30 days for G to figure out the new 'plan' of your site and re-assign all the page-ranking factors from and to the new URLs. Best advice is to leave the site alone and work on something else, and let them get this done before making any further changes.

Jim

g1tech

4:07 pm on Mar 7, 2007 (gmt 0)

5+ Year Member



Hello, to update the thread, it has been exactly 30 days since we implemented the 301 redirect - Google and Yahoo still have our old URL in their indexes. MSN has updated properly.

Can someone verify the code that we used is correct?

------------------
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) [newdomain.com...] [R=301,L]
------------------

It forwards incoming traffic from www.olddomain.com/anypage.htm to www.newdomain.com/anypage.htm perfectly, but Google and Yahoo haven't updated their index with www.newdomain.com yet. Meanwhile our SERP's on G and Y continue to drop.

Maybe the answer is simply more patience..

jdMorgan

7:45 pm on Mar 7, 2007 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



If both olddomain and newdomain point to the same server filespace, then you will need to tell this rewrite rule not to redirect newdomain to itself, which it will do unless told otherwise.

Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{HTTP_HOST} !^www\.newdomain\.com
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

The added RewriteCond prevent the rule from being applied unless the requested domain is NOT "www.newdomain.com"

As with any change to your server configuration, I strongly suggest that you use something like the "Live HTTP Headers" extension to Firefox to carefully check the server response headers sent by your server. You should see one and only one 301-Moved Permanently response when requesting any page on "olddomain.com".

Jim

g1tech

8:41 pm on Mar 7, 2007 (gmt 0)

5+ Year Member



Thanks for the reply, Jim. The two sites (olddomain.com, newdomain.com) are hosted at two different webhosts altogether.

Would we still have to make this adjustment?

I'll look into the Live HTTP headers now...

g1tech

8:53 pm on Mar 7, 2007 (gmt 0)

5+ Year Member



Here is the result of the HTTP Headers:

-----------------------
[olddomain.com...]

GET /anypage.htm HTTP/1.1
Host: www.olddomain.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.10) Gecko/20070216 Firefox/1.5.0.10
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cookie: __utma=103541569.1270042340.1156519102.1165820082.1167790803.17; www%2Epro%2FCustomerID=1

HTTP/1.x 301 Moved Permanently
Date: Wed, 07 Mar 2007 20:50:30 GMT
Server: Apache/1.3.33 (Unix)
Location: [newdomain.com...]
Keep-Alive: timeout=2, max=199
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1

jdMorgan

9:18 pm on Mar 7, 2007 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Looks fine. So it's all down to waiting for the old URLs to be spidered, the new URLs to be substituted, and then (in a second phase) for the PageRank to be assigned forward from old to new...

Jim

g1tech

9:32 pm on Mar 7, 2007 (gmt 0)

5+ Year Member



Jim, thanks again for your help with this. Confidence is restored. I'll post updates periodically when appropriate...
 

Featured Threads

Hot Threads This Week

Hot Threads This Month