2011-09-05 76 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