问题描述:

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, i.e. 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

相关阅读:
Top