简体   繁体   中英

301 Redirects Old Domain to New Domain

Im looking at moving domains for my site.

The first part of the url will change ie www.olddomain.co.uk to www.newdomain.co.uk. However the second part of the domain will stay the same.

Do I place my htaccess with the redirects on my old server or new server?

Thanks

I'm assuming by "second part" you mean the part of the URL after the domain, ie for http://www.somedomain.co.uk/index.php , the first part is http://www.somedomain.co.uk/ and the second is index.php .

You can redirect this using a mod_rewrite rule in your .htaccess on your old domain (assuming you have permission to do so and mod_rewrite is installed). Something like this should do the trick:

RewriteEngine on
RewriteRule   ^/(.+)$  http://www.newdomain.co.uk/$1  [R=301,L]

You could also use a RedirectMatch (supplied by mod_alias) if you don't have mod_rewrite:

RedirectMatch ^/(.*) http://www.newdomain.co.uk/$1

This should give you more information on mod_rewrite remapping: http://httpd.apache.org/docs/2.4/rewrite/remapping.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM