2012-08-29 47 views
0

我在嘗試正確格式化重定向時遇到了一些困難。 我有以下幾點:正確語法的重定向URL

RedirectMatch 301 http://mooseburger.com/onlinestore/index.cgi?code=3&cat=7 
https://www.mooseburgeronline.com/categories/Clown-Costumes-/Coats%2C-Jackets-%26-Vests/ 

我知道它有什麼做的%或&跡象。你如何逃避他們?

回答

0

我認爲RedirectMatch的模式應該是一個絕對的URL(如「/ onlinestore/something」)或相對於htaccess位置的URL(如「onlinestore/something」)。另外,不幸的是,RedirectMatch模式無法與查詢字符串匹配。正如Rekire所建議的那樣,您需要使用mod_rewrite。語法將沿着這些線:

RewriteEngine on 

RewriteCond %{QUERY_STRING} \bcode=(3)\b 
RewriteCond %{QUERY_STRING} \bcat=(7)\b 
RewriteRule ^onlinestore/index.cgi https://www.mooseburgeronline.com/categories/Clown-Costumes-/Coats%2C-Jackets-%26-Vests/? [NC] 

這也剝離原始查詢字符串。我沒有測試過,但這應該讓你開始。

一些鏈接:

當然谷歌會給你數百個體面的教程。

+0

這是行不通的。我不在乎它是否重定向到新的類別。我只需要它從:http://mooseburger.com/onlinestore/index.cgi(這裏會有更多的數據)到http://mooseburgeronline.com – user1634009

+0

不工作怎麼樣?無論如何,如果你不關心細節,'RedirectMatch 301 ^/onlinestore https:// www.mooseburgeronline.com /'應該重定向以'/ onlinestore'開始的所有內容。 –