2009-12-31 19 views
0

這是我的httpd.conf文件http://old.example.com位置欄不顯示重定向的URL

RewriteEngine on 
RewriteBase/
RewriteRule ^login$ http://another.example.com/login [L] 

的問題是,雖然我可以重定向到http://another.example.com/login,但地址欄仍是顯示http://old.example.com/login

任何想法如何解決這個問題?

回答

6

如果你在server or virtual host configuration使用mod_rewrite,你總是需要在你的模式,以指定完整的URL路徑:在.htaccess文件在每個目錄上下文中使用就像當

RewriteRule ^/login$ http://another.example.com/login [L,R] 

只有你只需要指定沒有上下文路徑前綴的相對URL路徑即可。

而且還通過設置R flag嘗試一個明確的重定向:

RewriteRule ^/login$ http://another.example.com/login [L,R] 

有了,你還可以指定一個狀態代碼:

RewriteRule ^/login$ http://another.example.com/login [L,R=301]