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.
How do I 301 a domain (but keep rest of URL) to new domain?
Moderator: General Moderators
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
How do I 301 a domain (but keep rest of URL) to new domain?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: How do I 301 a domain (but keep rest of URL) to new doma
Check out the Redirect directive.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: How do I 301 a domain (but keep rest of URL) to new doma
Code: Select all
RewriteCond "%{HTTP_HOST}" "!^www\." [NC]
RewriteCond "%{HTTP_HOST}" "!^$"
RewriteRule "^/?(.*)" "http://www.%{HTTP_HOST}/$1" [L,R,NE]Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: How do I 301 a domain (but keep rest of URL) to new doma
No, "Redirect". Although you could use mod_rewrite to do it too (but not with that stuff you posted).
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: How do I 301 a domain (but keep rest of URL) to new doma
So how .. ?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: How do I 301 a domain (but keep rest of URL) to new doma
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.
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.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: How do I 301 a domain (but keep rest of URL) to new doma
Go back and read it again. Specifically the bit about status.simonmlewis wrote:That's not a 301.