2014-11-17 65 views
1

我之前使用過其他主機,一切正常,但現在我已將其更改爲新的。在新主機上安裝apache 2.4。mod_rewrite在apache 2.4上工作不正確

我的下一個規則:

<IfModule mod_rewrite.c> 
     RewriteEngine on 
     RewriteBase/
     RewriteCond %{HTTP_HOST} ^www\.(.*) [NC] 
     RewriteRule ^/?(.*) http://%1/$1 [L,R=permanent] 

     RewriteRule manage/ajax/(.*?)$ manage/ajax/index.php [QSA,L] 
     RewriteRule manage/json/(.*?)$ manage/json/index.php [QSA,L] 

     RewriteCond %{REQUEST_URI} !\.(.+)$ 
     RewriteRule ckfinder/(.*?)$ ckfinder/index.html [QSA,L] 

     RewriteCond %{REQUEST_URI} !\.(.+)$ 
     RewriteRule manage/(.*?)/$ manage/index.php [QSA,L] 

     RewriteCond %{REQUEST_URI} !\.(.+)$ 
     RewriteRule ajax/(.+?) ajax/index.php [QSA,L] 

     RewriteCond %{REQUEST_URI} !\.(.+)$ 
     RewriteRule api/(.*?) /api/index.php [QSA,L] 

     RewriteCond %{REQUEST_URI} !\.(.+)$ 
     RewriteRule (.*) index.php 
</IfModule> 

當我嘗試訪問例如/管理/它告訴我的索引頁,但如果我將一些額外的數據添加到路徑它會告訴我我需要什麼。例如:/manage/some_data - 工作正常。但我想通過/manage/訪問正確的目錄。

+1

在你的.htaccess – anubhava

+0

感謝的頂部,即固定我的問題只是用'的DirectoryIndex index.php'。 – user2058653

+0

不客氣,很高興幫助。 – anubhava

回答

2

將此規則更改爲:

RewriteCond %{REQUEST_URI} !\.(.+)$ 
RwriteRule manage/(.*?)/$ manage/index.php [QSA,L] 

RewriteCond %{REQUEST_URI} !\.(.+)$ 
RwriteRule manage(/.*)?$ manage/index.php [QSA,L] 
+0

同樣的結果,沒有什麼改變。 – user2058653

+0

絕對確定您輸入的內容正確嗎?正則表達式應該工作。看到這裏:http://regex101.com/r/jN1jA8/2 – arco444

+0

我不認爲這個問題是在正則表達式,因爲我的規則在舊服務器上正常工作。我認爲在邏輯上有問題,也許在新的Apache與mod_rewrite更改? – user2058653