最近更新PHP版本从7.3.26到7.3.27遇到的坑记录一下。
通过以往的正常方法开启了伪静态规则,访问网页时却报出下面让人头疼的错误提示:
- Internal Server Error
- The server encountered an internal error or misconfiguration and was unable to complete your request.
- Please contact the server administrator at admin@example.com to inform them of the time this error occurred, and the actions you performed just before this error.
- More information about this error may be available in the server error log.
我确认伪静态已经启用了,因为将程序目录中只要.htaccess文件删除,网站就可以正常访问默认首页的。说明至少PHP可以正常运行,但是发现访问经过静态规则设置的其他目录却无法访问。最后经过测试,发现了问题所在,就是自己的.htaccess的写法已经与新版本的PHP不兼容了。之前在我的.htaccess文件都会写上以下代码:
- <Files ~ "^.(htaccess|htpasswd)$">
- deny from all
- </Files>
- order deny,allow
- RewriteEngine on
这就是造成显示错误的原因,因为在httpd.conf文件中有一段代码:
- <Files ".ht*">
- Require all denied
- </Files>
这个其实已经实现了拒绝他人访问.ht开头的文件,已经有保护作用了。所以修改自己的.htaccess文件,只保留了如下代码:
- RewriteEngine on
再刷新网站,已经可以正常访问了。同时还应该注意一下,有如下正则的代码也要一并去掉,否则和上面的错误一样。所以遇到上面的错误,先把.htaccess拿掉再看,逐步缩小错误范围。
- <Files ~ ".(sql|rar)$">
- order deny,allow
- deny from all
- allow from 10.64.10.17
- allow from 10.64.10.251
- </Files>
以上就是Internal Server Error错误和.htaccess伪静态的关系的详细内容,更多关于Internal Server Error错误和.htaccess伪静态的关系的资料请关注九品源码其它相关文章!