开发者

Redirect old directory to new website

I want to use htaccess to redirect all traffic from www.oldsite.com/directory to www.newsite.com

I want to make it so that when visitors view any webpage within www.oldsite.com/directory (ie. www.oldsite.com/directory/contact.html) it gets re开发者_运维技巧directed to the homepage of www.newsite.com

I tried "Redirect /directory http:www.newsite.com" but the webpage the visitor is trying to access within the directory gets attached to the new sites url (ie. www.newsite.com/contact.html)


You can use mod_proxy to setup reverse proxy on the old site. Configuration within the old site would look something like this:

ProxyRequests Off

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

ProxyPass /directory http://www.newsite.com
ProxyPassReverse /directory http://www.newsite.com

Make sure you activate mod_proxy and mod_proxy_http modules.

You can also use the mod_rewrite module with the force-proxy [P] flag on the end of the RewriteRule directive. That would look something like this:

RewriteRule ^/directory(.*) http://www.newsite.com$1 [P]

The last option would be to use just plain external redirection:

RewriteRule ^/directory(.*) http://www.newsite.com$1

You can read a bit about mod_proxy and/or mod_rewrite. You may even get some better ideas.

http://httpd.apache.org/docs/2.2/mod/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜