2012-09-29 29 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它不應該重定向,它應該只是爲您提供內容。 –