2012-09-29 28 views
0
不同的结果

我已经设置了以下重写规则的mod_rewrite对Windows和Ubuntu的

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ core/index.php [L] 

和网站架构是

newsite 
﹂ .htaccess 
﹂ core 
    ﹂ index.php 

如果我使用的网址:HTTP ://本地主机/ web/newsite/test在Windows上
它将重定向到/web/newsite/core/index.php
和这行得通!

但如果使用url 的http://本地主机/〜USER1 /网络/ newsite /测试在Ubuntu
会重定向到/home/user1/public_html/web/newsite/core/index.php
/~user1/web/newsite/core/index.php

所以,我怎么能解决这个问题?
谢谢!

回答

0

添加RewriteBase你上面的规则:

RewriteBase /~user1/web/newsite/ 

Apache就Ubuntu是试图猜测,如果重写规则的目标是一个URI路径或文件路径和它的猜测不正确,因此你必须告诉它什么是真正的相对URI基础。

+0

感谢您的回答,但是如果我使用RewriteBase,我必须在每个服务器中设置不同的RewriteBase。 那么,有什么办法可以解决问题吗? –

+0

@AzureChen它不应该重定向,它应该只是为您提供内容。 –