故障使用的.htaccess删除html的URL扩展(Trouble removing .html

2019-06-24 15:22发布

试图删除使用.htaccess中的网站HTML扩展。 因此,例如:www.mysite.com/charts.html将成为www.mysite.com/charts

下面的脚本是在.htaccess文件中:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ /$1 [L,R=301]

但是,当在浏览器中输入不.html扩展名的URL,它显示了一个403 Forbidden错误。 任何帮助,将不胜感激。

Answer 1:

我发现这个解决方案在别处:

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

来源:1) http://www.catswhocode.com/blog/10-useful-htaccess-snippets-to-have-in-your-toolbox 2) http://eisabainyo.net/weblog/2007/08/19 /移除文件扩展-通htaccess的/



文章来源: Trouble removing .html URL extension using .htaccess