Gra*_*ton 0 apache mod-rewrite httpd.conf
这是我的httpd.conf文件http://old.example.com
:
RewriteEngine on
RewriteBase /
RewriteRule ^login$ http://another.example.com/login [L]
Run Code Online (Sandbox Code Playgroud)
问题是虽然我可以重定向到http://another.example.com/login
,但位置栏仍然显示http://old.example.com/login
.
知道如何解决这个问题吗?
如果您在服务器或虚拟主机配置中使用mod_rewrite,则始终需要在模式中指定完整的URL路径:
RewriteRule ^/login$ http://another.example.com/login [L,R]
Run Code Online (Sandbox Code Playgroud)
只有在.htaccess文件中的每个目录上下文中使用时,才需要指定不带上下文路径前缀的相对URL路径.
并且还可以通过设置R标志来尝试显式重定向:
RewriteRule ^/login$ http://another.example.com/login [L,R]
Run Code Online (Sandbox Code Playgroud)
有了它,您还可以指定状态代码:
RewriteRule ^/login$ http://another.example.com/login [L,R=301]
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
357 次 |
最近记录: |