WAMP - 尾随斜杠 (/) 给出错误 500 "Internal Server Error" - .htaccess 错误?



我在电脑上使用WAMP,在编写网站代码时,我决定删除.html扩展名,希望提高美观性。

这工作正常,所以,就我而言,temp.jakegriffin.co.uk/index.html 变成了我想要的/index。不幸的是,如果有一个尾随/后索引,我会得到:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete     your request.
Please contact the server administrator, admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.

当我尝试在.htaccess文件中解决此问题时,我要么收到错误403,要么收到错误403,因为我被禁止,或者错误404是页面不存在。

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

这是我的.htaccess文件中用于删除扩展名的代码。如果有人能帮助我,将不胜感激。

提前感谢,杰克。

这个

mod_rewrite规则:

 * http://planetozh.com/blog/2004/05/apache-and-the-trailing-slash-problem/
    RewriteEngine  on
    RewriteBase    /
    RewriteCond    %{REQUEST_FILENAME}  -d
    RewriteRule    ^(.+[^/])$ $1/

试试这个:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)[/*]$ $1.html [L,NC]

现在您可以在index ;)后添加一堆正斜杠 (/)

相关内容

最新更新