我在解决如何在删除文件扩展名后正确重写查询字符串时遇到问题。
我当前的代码产生错误500:Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
这是我的htaccess重写:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
RewriteRule ^login/([a-zA-Z0-9-=_?]+)/?$ login.php?user=$1 [L,QSA]
删除最后一行(RewriteRule ^login/([a-zA-Z0-9-=_?]+)/?$ login.php?user=$1 [L,QSA]
)后,服务器错误消失。
我需要做些什么才能实现这一目标?
答案 0 :(得分:0)
按此顺序制定规则:
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^login/([\w=-]+)/?$ login.php?user=$1 [L,QSA,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]