RedirectMatch无法正常工作

时间:2012-07-13 08:06:58

标签: mod-rewrite redirect url-rewriting

我有这个网址:

http://www.example.com/prospective/deginfo.php?classname=PE&diploma_description=BSc+in+Mathematical+Sciences

我需要重定向到此网址:

http://www.example.ie/prospective/deginfo.php?classname=PEC&diploma_description=BSc+in+Mathematical+Sciences+with+French+%27Bachelor+Honours+Degree%27

我认为我可以使用RedirectMatch执行以下操作以“捕获”Bsc之前的所有内容,并从那里将其重定向到我想要的网址但不起作用:

RedirectMatch ^/.*BSc\+in\+Physical\+Education http://www.example.ie/prospective/deginfo.php?classname=PEC&degree_description=BSc+in+Mathematical+Sciences+with+French+%27Bachelor+Honours+Degree%27

有人可以告诉我我做错了什么以及如何纠正吗?

1 个答案:

答案 0 :(得分:2)

您无法与RedirectMatch中的查询字符串匹配,它只与URI匹配。您可以使用mod_rewrite和RewriteCond

匹配它
RewriteEngine On

RewriteCond %{QUERY_STRING} ^classname=PE&diploma_description=BSc\+in\+Mathematical\+Sciences$
RewriteRule ^/?prospective/deginfo.php$ /prospective/deginfo.php?classname=PEC&degree_description=BSc+in+Mathematical+Sciences+with+French+'Bachelor+Honours+Degree' [L,R]