htaccess文件无法正常工作

时间:2012-05-16 07:03:24

标签: php .htaccess

我有一个.htaccess文件,其中包含以下代码:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteCond %{REQUEST_URI} (/|\.html|/[^.]*)$ [NC]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^([A-Za-z0-9-_]+)/?$ $1.html [NC]
</IfModule>

但它不起作用。我想更改网址,例如www.example.com/about.htmlwww.example.com/about,依此类推。

1 个答案:

答案 0 :(得分:3)

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html

如果您下次不理解,请将其保存在.htaccess代码段文件中。将.html替换为您需要删除的文件扩展名。

相关问题