我想使用htaccess重写来显示没有扩展名的单页。单页.htaccess重写
http://site.com/account 到 http://site.com/account.php
RewriteEngine on
RewriteRule ^account$ /account.php [L]
不应该工作的呢?它什么也没做。
我也尝试了一般的,但没有工作,要么:
RewriteEngine on
RewriteRule ^(.*)/$ $1.php
我想使用htaccess重写来显示没有扩展名的单页。单页.htaccess重写
http://site.com/account 到 http://site.com/account.php
RewriteEngine on
RewriteRule ^account$ /account.php [L]
不应该工作的呢?它什么也没做。
我也尝试了一般的,但没有工作,要么:
RewriteEngine on
RewriteRule ^(.*)/$ $1.php
启用重写模块?也许尝试检查以斜线结尾的URL。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^account\/\?$ /account.php [L]
</IfModule>
我的建议是使用动态规则,而不是静态的规则:
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
后,我仍然获得/账户404和/帐号/ – stackers