这是我的httpd.conf文件http://old.example.com
:
RewriteEngine on
RewriteBase /
RewriteRule ^login$ http://another.example.com/login [L]
问题是虽然我可以重定向到http://another.example.com/login
,但位置栏仍然显示http://old.example.com/login
。
知道如何解决这个问题吗?
这是我的httpd.conf文件http://old.example.com
:
RewriteEngine on
RewriteBase /
RewriteRule ^login$ http://another.example.com/login [L]
问题是虽然我可以重定向到http://another.example.com/login
,但位置栏仍然显示http://old.example.com/login
。
知道如何解决这个问题吗?
如果您在服务器或虚拟主机配置中使用 mod_rewrite,则始终需要在模式中指定完整的 URL 路径:
RewriteRule ^/login$ http://another.example.com/login [L,R]
仅当在每个目录上下文中使用时,例如在 .htaccess 文件中,您只需要指定不带上下文路径前缀的相对 URL 路径。
并通过设置R标志尝试显式重定向:
RewriteRule ^/login$ http://another.example.com/login [L,R]
有了它,您还可以指定状态代码:
RewriteRule ^/login$ http://another.example.com/login [L,R=301]