2011-09-05 74 views

回答

0

啓用重寫模塊?也許嘗試檢查以斜線結尾的URL。

<IfModule mod_rewrite.c> 
RewriteEngine On 

RewriteRule ^account\/\?$ /account.php [L] 
</IfModule> 
+0

後,我仍然獲得/賬戶404和/帳號/ – stackers

0

我的建議是使用動態規則,而不是靜態的規則:

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteCond %{REQUEST_URI} !/$ 
RewriteRule (.*) $1.php [L] 

這樣任何頁面引用任何PHP腳本。

例如:

http://site.com/account將加載http://site.com/account.php

http://site.com/login將加載http://site.com/login.php

如果你喜歡但是使用靜態重寫規則,那麼你可以使用以下命令:

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteCond %{REQUEST_URI} !/$ 
RewriteRule ^index index.php [L] 

我想指出,如果你打算使用這些Ë改寫爲腳本,位於子文件夾內的規則,像

http://site.com/myfolder/account

那麼這將是最好添加一個RewriteBase你發起RewriteEngine