Web Hosting Talk







View Full Version : Tricky domain redirect issue


ramdak5000
02-01-2008, 05:11 AM
A client has moved their site over to my server and simultaneously changed the domain name too. The old content is up and running on my new server and I am faced with two challenges:

1.) Redirect the old domain to point to my nameserver. I don't want to park their old domain on the new one as it may give rise to duplicate content issues. Luckily, they have full control over the old domain's control panel, so it was easy for me to change the nameservers of the old domain to point to mine.

2.) More difficult is how I should let the search engines know that all the content has been permanently moved to my server. I am not sure how this is done. I have read about a 301 permanent redirect, but where exactly is this set?

The domain control panel for the old domain is not great in terms of DNS management and the client does not want to continue hosting with their previous provider (which would give them an easier way to setup the permanent redirect, from what I know).

What options does the client have for telling Google et al that their old content has moved to the new domain? There has been no change whatsoever in the directory or page structure of the web site files.

Any assistance would be most helpful.

rony
02-01-2008, 07:12 AM
Park or point the old domain to the new one.

In the (public) html directory make or edit the file .htaccess

Put the following code into that file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*)\.olddomain\.oldextension$ [NC]
RewriteRule ^/(.*) http://www.newdomains.com/$1 [R=301,L]
</IfModule>


When your old domain was olddomain.com, then olddomain is "olddomain" and oldextension is "com".

ramdak5000
02-02-2008, 03:21 AM
Thanks a bunch.

Does this .htaccess go into the public_html of the old domain or the new one(new domain extension)?

rony
02-03-2008, 01:02 PM
as said you point the domain / park the domain on top of the other, therefore you have only one public_html and it goes in there.

ramdak5000
02-04-2008, 04:08 AM
as said you point the domain / park the domain on top of the other, therefore you have only one public_html and it goes in there.
Thanks for the help with this. One question - should I retain the space that I see in the third line of the rule?

rony
02-04-2008, 04:27 AM
one space is good enough. but you can have more if you want to have nice formating...

ramdak5000
02-04-2008, 08:30 AM
one space is good enough. but you can have more if you want to have nice formating...

Thanks:-)

One final question and I will stop bugging.

I didn't do a redirect from the old domain to the new one. Just parked it on top of the new domain and added the code to .htaccess. Is this okay or would it be better for me to redirect to the new domain even though the old one is parked and has the .htaccess code?

ramdak5000
02-04-2008, 09:05 AM
Okay, I looked into this a bit more as I wasn't getting the permanent redirect code when I checked the server headers. cPanel was also showing it as a temporary redirect, for whatever reason.

What I did was to:

1.) Remove the .htaccess file I had created based on your code
2.) Use cPanel's redirect function under the parked domain section
3.) This automatically set up a permanent redirect. The code differs slightly from what you suggested, so I am sharing it here:RewriteEngine on
RewriteCond %{HTTP_HOST} ^olddomain.tld$ [OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.tld$
RewriteRule ^(.*)$ http://www.newdomain.tld [R=301,L]

When I checked the server headers now, I get the 301 status message correctly. For anyone who is interested, doing a check server headers search in google turns up plenty of sites.

DephNet[Paul]
02-04-2008, 09:15 AM
The .htaccess I use when redirecting is:

RewriteEngine on

RewriteCond %{HTTP_HOST} !^www\.newdomain\.tld[NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^(.*) http://www.newdomain.tld/$1 [R=307]

I use a 307 rule because i *may* want to start using my old domain again.

Paul