当我使用此 htaccess 代码时,我从链接的 CSS 文件等中收到 500 内部服务器错误。有人知道可能是什么问题吗?我还不太熟悉htaccess。
这是代码:
RewriteEngine On
RewriteBase /
RewriteRule ^(system|img|res) - [L]
RewriteRule ^picture/([^/]*)/?$ picture.php?id=$1 [L,QSA]
## The below code is something I found on the internet to remove the .php tag
# remove .php; use THE_REQUEST to prevent infinite loops
RewriteCond %{HTTP_HOST} ^www\.mywebsite\.com
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP
RewriteRule (.*)\.php$ $1 [R=301]
# remove index
RewriteRule (.*)index$ $1 [R=301]
# remove slash if not directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ $1 [R=301]
# add .php to access file, but don't redirect
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
URL 应该是:www.mysite.com/pictures/1 (id)
id 始终是一个数字。
它确实向我显示了页面,并且我可以回显 ID,因此该部分正在工作,但是如上所述,它在链接文件上给了我 500 错误。