Forum Moderators: phranque

Message Too Old, No Replies

.htaccess newbie question

         

markbaa

4:34 am on Jan 31, 2006 (gmt 0)

10+ Year Member



I'm hoping this is about as simple as it gets, but I don't know my way around a htaccess file.

I am moving a site from domain1.com to domain2.com. The site will be identical, same paths, etc, the problem is domain1.com has some nice inbound links to want to maintain maximum google juice.

So how would I create a .htaccess to redirect visitors & bots from domain1.com/*.* to domain2.com/*.*?

Cheers,

Mark

jdMorgan

4:54 am on Jan 31, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are both domains hosted on the same server?
If so, are they really the same "account" on that server?

The complexity of the solution depends on these factors.

Jim

ogletree

5:13 am on Jan 31, 2006 (gmt 0)

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



Why do you need to transfer the domain? Is the new domain new. More than likely whatever you do you will kill all your se traffic for quite a while.

But if you need to all you have to do is 301 all the files. You can set up the htacces so that it sends any request to domain1 to domain2 with the same path.

markbaa

6:40 am on Jan 31, 2006 (gmt 0)

10+ Year Member



There's business reasons for changing the domain which outweight potential traffic loss, but want to minimise it. They are on different servers. Can't do a 301 on the actual files as they are .html.

Which leads back to the original question, how do I use .htaccess to do this? (assuming I can).

jdMorgan

2:11 pm on Jan 31, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> They are on different servers.

This makes it easy. On the server for the old domain, place the following line in a plain-text file named ".htaccess" in the top-level Web-accesible directory (where the site's "home page" is currently located):


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

This will redirect *all* requests to the new domain, barring any server configurations that prevent it.

After testing, you may remove all of your files from the old server, since they will no longer be accessible. The effect will be immediate, but you will need to flush your browser cache before testing to get valid results.

Jim