【发布时间】:2011-10-06 04:32:51
【问题描述】:
我在 Google 和 stackoverflow 上搜索了超过 48 小时,但没有找到类似的问题/解决方案;因此,我寻求帮助。
如果我想重写http://localhost/filename等URL来获取filename.php(这样localhost/aboutus获取aboutus.php,localhost/contact获取contact.php等)。
我该怎么做?我不想为每一页写一条规则;我希望“文件名”是动态的,以便单个规则适用于特定文件夹中的所有页面。
我试过了:
RewriteRule ^(.*)/?$ $1.php
在 .htaccess 文件中,我不断收到 500 错误。
谢谢。
整个文件包含以下内容:
重写引擎开启
RewriteBase /
重写规则 ^(.*)/?$ $1.php
这就是文件包含的所有内容
【问题讨论】:
-
请发布您的整个 .htaccess 文件。该规则应该有效。
-
我已修改问题以包含文件的内容。谢谢
标签: .htaccess mod-rewrite