【发布时间】:2017-11-08 04:15:29
【问题描述】:
这是我的 .htaccess 代码
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.php -f
RewriteRule ^test8/([^-]*)$ /test8.php?idval=$1 [L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
DirectoryIndex index.php
ErrorDocument 404 https://www.example.com/
ErrorDocument 403 https://www.example.com/
当我尝试访问example.com/test8/123456时
应该是Internal Server Error
但是当我通过在第一个代码行添加此行来编辑 .htaccess 以用于 mod 重写 URL。
RewriteRule ^test7/([^-]*)$ /test7.php?idval=$1 [L]
喜欢这个
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.php -f
RewriteRule ^test7/([^-]*)$ /test7.php?idval=$1 [L]
RewriteRule ^test8/([^-]*)$ /test8.php?idval=$1 [L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
DirectoryIndex index.php
ErrorDocument 404 https://www.example.com/
ErrorDocument 403 https://www.example.com/
当我尝试访问example.com/test8/123456 时,它工作得很好。
但是当我尝试访问example.com/test7/123456 时,它将是Internal Server Error
我想知道为什么在 mod rewrite URL 的第一个代码行上仍然 Internal Server Error ?我该怎么办?
【问题讨论】:
-
我认为
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.php -f会导致内部错误。如果你评论它,然后尝试它。
标签: php apache .htaccess mod-rewrite