一个服务器上的奇怪mod_rewrite问题,但不是另一个服务器

时间:2011-04-07 21:16:46

标签: .htaccess mod-rewrite

我写了一些mod_rewrites在一台服务器上工作正常,但没有另外一台

mod_rewrite一般都在工作,例如转到http://site/about会将我带到服务器A和服务器B上的about.php

但是当mod_rewrite进入另一个级别前进时,服务器B上发生了一些奇怪的事情

例如,在服务器A上,当我访问http://site/submit/bulk时,它会将我带到submit_bulk.php,但是当我访问服务器B上的相同位置时,它会将我带到submit.php。就像在第二台服务器上它选择第一个mod_rewrite匹配(/ submit)并且不继续寻找实际匹配(/ submit / bulk)。

同样的问题发生在底部的rss位,rss / submissions / nick在服务器A上正常工作,但在服务器B上它显然只是转到没有参数传递的rss.php

你能看出可能出现的问题吗?

谢谢

IndexIgnore *
ErrorDocument 404 /404.php

RewriteEngine on
RewriteRule ^all-time/?$ "index.php?mode=all-time"
RewriteRule ^all-time/cat/([^/\.]+)/?$ index.php?mode=all-time&cat=$1 [L]
RewriteRule ^all-time/cat/([^/\.]+)/p/([^/\.]+)/?$ index.php?mode=all-time&cat=$1&p=$2 [L]
RewriteRule ^all-time/p/([^/\.]+)/?$ index.php?mode=all-time&p=$1 [L]
RewriteRule ^cat/([^/\.]+)/?$ index.php?cat=$1 [L]
RewriteRule ^cat/([^/\.]+)/p/([^/\.]+)/?$ index.php?cat=$1&p=$2 [L]
RewriteRule ^comment/?$ "comment.php"
RewriteRule ^comments/?$ "comment_list.php"
RewriteRule ^delete/c/([^/\.]+)/?$ delete_comment.php?comment=$1 [L]
RewriteRule ^delete/p/([^/\.]+)/?$ delete_post.php?post=$1 [L]
RewriteRule ^delete/u/([^/\.]+)/?$ delete_user.php?user=$1 [L]
RewriteRule ^edit/p/([^/\.]+)/?$ submit.php?post=$1 [L]
RewriteRule ^edit/u/([^/\.]+)/?$ edit_user.php?user=$1 [L]
RewriteRule ^forgot/?$ "forgot.php"
RewriteRule ^login/?$ "login.php"
RewriteRule ^new/?$ "index.php?mode=new"
RewriteRule ^new/p/([^/\.]+)/?$ index.php?mode=new&p=$1 [L]
RewriteRule ^new/cat/([^/\.]+)/?$ index.php?mode=new&cat=$1 [L]
RewriteRule ^new/cat/([^/\.]+)/p/([^/\.]+)/?$ index.php?mode=new&cat=$1&p=$2 [L]
RewriteRule ^p/([^/\.]+)/?$ index.php?p=$1 [L]
RewriteRule ^register/?$ "register.php"
RewriteRule ^reset/about/?$ "reset_about.php"
RewriteRule ^reset/email/?$ "reset_email.php"
RewriteRule ^reset/forgot?$ "reset_forgot.php"
RewriteRule ^reset/pw/?$ "reset_pw.php"
RewriteRule ^search/?$ "search.php"
RewriteRule ^submit/?$ "submit.php"
RewriteRule ^submit/bulk/?$ "submit_bulk.php"
RewriteRule ^submissions/([^/\.]+)/?$ index.php?mode=submit&user=$1 [L]
RewriteRule ^submissions/([^/\.]+)/p/([^/\.]+)/?$ index.php?mode=submit&user=$1&p=$2 [L]
RewriteRule ^submissions/([^/\.]+)/cat/([^/\.]+)/?$ index.php?mode=submit&user=$1&cat=$2 [L]
RewriteRule ^submissions/([^/\.]+)/cat/([^/\.]+)/p/([^/\.]+)/?$ index.php?mode=submit&user=$1&cat=$2&p=$3 [L]
RewriteRule ^u/([^/\.]+)/?$ profile.php?user=$1 [L]
RewriteRule ^u/([^/\.]+)/comments/?$ comment_list.php?user=$1 [L]
RewriteRule ^u/([^/\.]+)/comments/p/([^/\.]+)/?$ comment_list.php?user=$1&p=$2 [L]
RewriteRule ^ulist/?$ "user_list.php"
RewriteRule ^v/([^/\.]+)/?$ view.php?post=$1 [L]
RewriteRule ^voted/([^/\.]+)/?$ index.php?mode=vote&user=$1 [L]
RewriteRule ^voted/([^/\.]+)/p/([^/\.]+)/?$ index.php?mode=vote&user=$1&p=$2 [L]
RewriteRule ^voted/([^/\.]+)/cat/([^/\.]+)/?$ index.php?mode=vote&user=$1&cat=$2 [L]
RewriteRule ^voted/([^/\.]+)/cat/([^/\.]+)/p/([^/\.]+)/?$ index.php?mode=vote&user=$1&cat=$2&p=$3 [L]

RewriteRule ^rss/?$ "rss.php"
RewriteRule ^rss/all-time/?$ "rss.php?mode=all-time"
RewriteRule ^rss/all-time/cat/([^/\.]+)/?$ rss.php?mode=all-time&cat=$1 [L]
RewriteRule ^rss/cat/([^/\.]+)/?$ rss.php?cat=$1 [L]
RewriteRule ^rss/new/?$ "rss.php?mode=new"
RewriteRule ^rss/new/cat/([^/\.]+)/?$ rss.php?mode=new&cat=$1 [L]
RewriteRule ^rss/submissions/([^/\.]+)/?$ rss.php?mode=submit&user=$1 [L]
RewriteRule ^rss/submissions/([^/\.]+)/cat/([^/\.]+)/?$ rss.php?mode=submit&user=$1&cat=$2 [L]
RewriteRule ^rss/voted/([^/\.]+)/?$ rss.php?mode=vote&user=$1 [L]
RewriteRule ^rss/voted/([^/\.]+)/cat/([^/\.]+)/?$ rss.php?mode=vote&user=$1&cat=$2 [L]

2 个答案:

答案 0 :(得分:0)

您是否不想将更具体的条件移到列表中更高的位置,以便最大限度地减少重定向的数量?即将/ server / bulk条件放在第一位,这样它甚至不会达到/ submit条件。

否则,有一个mod_rewrite选项可以检入httpd.conf或.htaccess中的MaxRedirects,这可以防止重定向进入无限循环。我相信MaxRedirects默认设置为10,但可能在服务器上设置为1,这很奇怪。您可以通过设置RewriteOptions MaxRedirects=10

在.htaccess中覆盖它

答案 1 :(得分:0)

在我的000默认文件中,我注意到:

选项索引FollowSymLinks MultiViews AllowOverride all 订单允许,拒绝 允许所有人

删除MultiViews似乎可以解决问题