2012-07-13 57 views
0

我有這個網址:RedirectMatch不工作

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 

任何人都可以建議我做錯了什麼,請問如何糾正?

回答

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] 
+0

謝謝喬恩的解釋和幫助 - 完美的作品 – frodo 2012-07-13 08:42:07