301 redirect for New Domain, Same Site
5 posts
• Page 1 of 1
301 redirect for New Domain, Same Site
Hello,
I have never had this situation before, but I have a website that is going to change their domain name but everything about their site will be the same, pages, links, etc.
In order to keep their search rankings I want to put a 301 redirect on their old domain site to direct all traffic to their new domain. What would be the best way to do this?
Thanks,
John
I have never had this situation before, but I have a website that is going to change their domain name but everything about their site will be the same, pages, links, etc.
In order to keep their search rankings I want to put a 301 redirect on their old domain site to direct all traffic to their new domain. What would be the best way to do this?
Thanks,
John
Re: 301 redirect for New Domain, Same Site
Hello, John
Yes, this is what is usually done in such situations.
The following code can be used in httpd.conf:
RewriteCond %{HTTP_HOST} olddomain.com [NC]
RewriteRule (*) http\://www.newdomain.com$1 [R=301,L]
Yes, this is what is usually done in such situations.
The following code can be used in httpd.conf:
RewriteCond %{HTTP_HOST} olddomain.com [NC]
RewriteRule (*) http\://www.newdomain.com$1 [R=301,L]
Re: 301 redirect for New Domain, Same Site
Thanks Anton,
The only modification I needed was to add (.*) instead of (*)
RewriteRule (.*) http\://www.newdomain.com$1 [R=301,L]
What would need to be changed to include all sub-directories as well?
Thanks,
John
The only modification I needed was to add (.*) instead of (*)
RewriteRule (.*) http\://www.newdomain.com$1 [R=301,L]
What would need to be changed to include all sub-directories as well?
Thanks,
John
Re: 301 redirect for New Domain, Same Site
Hello, John
The rule you have will redirect ALL requests to the old domain to the new one (including all subfolders).
Please try and if it doesn't work for some reason, please enable logging in httpd.conf by putting
RewriteLogLevel 9
and then provide rewrite.log records for the non-working request.
The rule you have will redirect ALL requests to the old domain to the new one (including all subfolders).
Please try and if it doesn't work for some reason, please enable logging in httpd.conf by putting
RewriteLogLevel 9
and then provide rewrite.log records for the non-working request.
Re: 301 redirect for New Domain, Same Site
Hi Anton,
I was able to get it to work by adding a / after the domain name in the rewrite rule. So I have it set to this now and it works:
RewriteRule (.*) http\://www.newdomain.com/$1 [R=301,L]
Thank you so much for your help I really appreciate it!
I was able to get it to work by adding a / after the domain name in the rewrite rule. So I have it set to this now and it works:
RewriteRule (.*) http\://www.newdomain.com/$1 [R=301,L]
Thank you so much for your help I really appreciate it!
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 22 guests