2012-11-19 27 views
2

我試圖重寫一個包含&符號的url。我試過&和%26,但都被apache剝離了。htaccess rewriterule - 逃避反向引用B標誌替代

例如,如果網址是:

healthyliving/fruit/apples_&_pears 

和重寫規則是:

RewriteRule ^healthyliving/fruit/([^/.]+)$ food.php?subpage=healthyliving&item=$1 [QSA,L] 

的查詢字符串會顯示 「apples_ & 梨」,但_GET['item']會顯示 「蘋果」 。

從我讀過的,大多數解決方案使用B標誌來逃避反向引用。這個標誌是在2.2.7中引入的。不幸的是,我們正在運行一個較早的版本,並且由於各種原因,我們現在不能升級。

有沒有辦法在不使用B標誌的情況下實現我所需要的功能?

回答

0

我不是很確定你想用$ _GET來完成的,但你可以試試這個

RewriteRule ^healthyliving/fruit/(.*)_&_(.*) food.php?subpage=healthyliving&item[]=$1&item[]=$2 [QSA,L] 

這應該給你:

Array ([subpage] => healthyliving [item] => Array ([0] => apples [1] => pears))