Page 1 of 1

How do I 301 a domain (but keep rest of URL) to new domain?

Posted: Tue Mar 01, 2016 3:48 am
by simonmlewis
Hi

We are moving a site from one domain to the other, but need to keep the rest of the URL.

ie. www.oldsite.co.uk/product/fgh/ert/11/test
Would now be: www.newsite.co.uk/product/fgh/ert/11/test

Is there a HTACCESS code I can pop in that will change the domain part of it?
I suspect it can be done in a PHP file, but also suspect it's possible in htaccess.

Re: How do I 301 a domain (but keep rest of URL) to new doma

Posted: Tue Mar 01, 2016 3:51 am
by requinix
Check out the Redirect directive.

Re: How do I 301 a domain (but keep rest of URL) to new doma

Posted: Tue Mar 01, 2016 4:00 am
by simonmlewis

Code: Select all

RewriteCond "%{HTTP_HOST}" "!^www\." [NC]
RewriteCond "%{HTTP_HOST}" "!^$"
RewriteRule "^/?(.*)"      "http://www.%{HTTP_HOST}/$1" [L,R,NE]
??

Re: How do I 301 a domain (but keep rest of URL) to new doma

Posted: Tue Mar 01, 2016 4:13 pm
by requinix
No, "Redirect". Although you could use mod_rewrite to do it too (but not with that stuff you posted).

Re: How do I 301 a domain (but keep rest of URL) to new doma

Posted: Wed Mar 02, 2016 1:36 am
by simonmlewis
So how .. ?

Re: How do I 301 a domain (but keep rest of URL) to new doma

Posted: Wed Mar 02, 2016 6:08 am
by Celauran

Re: How do I 301 a domain (but keep rest of URL) to new doma

Posted: Wed Mar 02, 2016 8:57 am
by simonmlewis
That's not a 301.
I'm certain there will be a simple one line code for htaccess, whereby it can tweak the http and domain part, but leave the rest, and 301 it onto the new site.

Re: How do I 301 a domain (but keep rest of URL) to new doma

Posted: Wed Mar 02, 2016 9:59 am
by Celauran
simonmlewis wrote:That's not a 301.
Go back and read it again. Specifically the bit about status.