301 redirect for New Domain, Same Site

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 41
Joined: 25 May 2012, 17:31

301 redirect for New Domain, Same Site

01 Jun 2012, 14:20

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

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: 301 redirect for New Domain, Same Site

05 Jun 2012, 05:43

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]

User avatar
Posts: 41
Joined: 25 May 2012, 17:31

Re: 301 redirect for New Domain, Same Site

05 Jun 2012, 15:15

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

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: 301 redirect for New Domain, Same Site

06 Jun 2012, 06:59

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.

User avatar
Posts: 41
Joined: 25 May 2012, 17:31

Re: 301 redirect for New Domain, Same Site

07 Jun 2012, 11:42

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!

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 22 guests