我有这个.htaccess文件,它运行正常:
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)$ /index.php?
locale=$1§ion=$2&action=$3&id=$4 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /index.php?locale=$1§ion=$2&action=$3 [L]
RewriteRule ^([^/]*)/([^/]*)$ /index.php?locale=$1§ion=$2 [L]
但是当我再添加一行时,对于一个参数,它会爆炸。这是最终文件:
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)$ /index.php?
locale=$1§ion=$2&action=$3&id=$4 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /index.php?locale=$1§ion=$2&action=$3 [L]
RewriteRule ^([^/]*)/([^/]*)$ /index.php?locale=$1§ion=$2 [L]
RewriteRule ^([^/]*)$ /index.php?locale=$1 [L]
这是错误消息:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at webmaster@mydomain.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.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
答案 0 :(得分:0)
您的服务器错误日志将包含类似的内容,
由于可能的配置错误,请求超出了10个内部重定向的限制。如有必要,使用'LimitInternalRecursion'增加限制。使用“LogLevel debug”获取回溯。
当mod_rewrite完成处理URL然后将其交还给URL解析器然后再对其执行重写规则时会发生这种情况,即使您第一次在其上有这些darn [L]
标志。前3个模式彼此不匹配,但最后一个匹配自己。
对于你似乎在做什么,这是美化URL,可能最简单的方法是简单地忽略以index.php开头的最后一条规则的路径:
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)$ /index.php?locale=$1§ion=$2&action=$3&id=$4
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /index.php?locale=$1§ion=$2&action=$3
RewriteRule ^([^/]*)/([^/]*)$ /index.php?locale=$1§ion=$2
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^([^/]*)$ /index.php?locale=$1