0

我有一个.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>

但它不起作用。我想更改 URL,例如www.example.com/about.htmltowww.example.com/about等等。

4

1 回答 1

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

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

于 2012-05-16T07:07:28.167 回答