2013-07-21 149 views
0

所以我在我的.htaccess中有一個Rewrite,它能正確處理我原來的計劃。.htaccess將無法正常工作

RewriteEngine on 
RewriteRule ^([^/]+)/?$ index.php?id=$1 [QSA] 

我有index.php?id = 4去/ 4 /。

的問題

如果我嘗試去到另一頁,雖然,它總是讓我回到index.php文件。例如,我有一個名爲「Update.php」的頁面。如果我去update.php,我被重定向到index.php

有什麼建議嗎?

由於提前,

+0

也許將'^ /'改爲'0-9'? – Class

回答

1

添加此行

RewriteCond %{REQUEST_FILENAME} !-f 

您的規則上面

這隻重寫時,文件不存在

+0

完美地工作。謝謝!我會稍微接受答案。 – user1834218

1
RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f #check if requested file not found 
RewriteCond %{REQUEST_FILENAME} !-d #check if requested directory not found 
RewriteRule ^([^/]+)/?$ index.php?id=$1 [QSA] #then apply the rule 

以上規則第一檢查請求的URI是否是真實的文件和文件夾,然後應用規則,這可以防止打開現有文件和文件夾時重定向。

+0

@toscho我做過了,你也可以免費添加你的編輯... – 2013-07-21 01:41:44