我需要更改传入的 http 请求
- 为了
www.pathfinder.com/T/client/care/login.html
- 看起来像
www.Theshop/care/login.html
在浏览器的“URL”行中。
如何使用“URL”重写来完成此操作?
我试过了
RewriteEngine on
RewriteRule "^www.pathfinder.com/T/clients/care/$" "www.Theshop.com/care/"
但这似乎不起作用。
答案1
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^/t/client/(care/.*)$ http://www.theshop.com/$1 [NC,R,L]
这将重定向
http://www.pathfinder.com/T/client/care/foo.html
或http://pathfinder.com/T/client/care/foo.html
到http://theshop.com/care/foo.html
使用标志
如果您只想重定向登录页面,请使用
RewriteRule ^/t/client(/care/login.html)$ http://www.theshop.com$1 [NC,R,L]