尝试访问不存在的文件或目录时出现500 Internal Server Error

时间:2018-11-20 05:04:46

标签: .htaccess server internals

很抱歉再次提出问题,但是我找不到任何可以帮助我的东西。

因此,我修改了.htaccess文件,以强制在URL后使用尾部斜杠,并删除了.html扩展名,尽管它可以正常工作,但我注意到当尝试访问不存在的文件时,它会触发500 500 Internal服务器错误页面,而不是404。感谢您的帮助!

网站:http://profastmovers.com 复制网址:http://profastmovers.com/xxx

.htaccess内容:

 RewriteEngine On
 RewriteBase /

 #Remove .html extension
 RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]
 RewriteRule ^ %1/ [NC,L,R]

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

 # Force trailing slash
 RewriteCond %{REQUEST_FILENAME}.html -f
 RewriteRule .*[^/]$ $0/ [L,R=301]

0 个答案:

没有答案