故障去除html的URL扩展使用的.htaccess [英] Trouble removing .html URL extension using .htaccess

查看:210
本文介绍了故障去除html的URL扩展使用的.htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Trying to remove .html extensions from the site using .htaccess. So for example: www.mysite.com/charts.html would become www.mysite.com/charts

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

The following script is in the .htaccess file:

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

但是,当没有.html扩展名的URL输入到浏览器中,它显示了一个403 Forbidden错误。任何帮助将是AP preciated。

But when the url without the .html extension is entered in the browser, it shows a 403 Forbidden error. Any help would be appreciated.

推荐答案

我在其他地方找到这个解决方案:

I found this solution elsewhere:

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

来源: 1)<一href="http://www.catswho$c$c.com/blog/10-useful-htaccess-snippets-to-have-in-your-toolbox">http://www.catswho$c$c.com/blog/10-useful-htaccess-snippets-to-have-in-your-toolbox 2)<一href="http://eisabainyo.net/weblog/2007/08/19/removing-file-extension-via-htaccess/">http://eisabainyo.net/weblog/2007/08/19/removing-file-extension-via-htaccess/

sources: 1) http://www.catswhocode.com/blog/10-useful-htaccess-snippets-to-have-in-your-toolbox 2) http://eisabainyo.net/weblog/2007/08/19/removing-file-extension-via-htaccess/

这篇关于故障去除html的URL扩展使用的.htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆