2011-09-29 90 views
0

我無法獲得某個url使用mod重寫進行重定向。我正在進行更多的基本重寫操作,所以這個功能發揮作用,所以我的網址出現問題。基於URL匹配的重定向

我在這裏嘗試了字符串,並將其顯示在拍打工程..

http://regexpal.com/

測試以下

RewriteCond %{HTTP_HOST} ^landed.at/component/jreviews/search-results/criteria:5/query:any/jr_country:sri-lanka/order:rdate$ 
    RewriteRule (.*) http://landed.at/itworked [L,R=301] 

我想其實拉的標準:5和jr_country:斯里蘭卡出我的變數 所以我的網址會變成

http://landed.at/tours/sri-lanka - tours if cr iteria:5和斯里蘭卡從jr_country

我得到沒有快速的正則表達式和爲什麼我的基本搜索匹配發生?根據regexpal它應該找到條件並進行重寫?

回答

0

你已經包含了一個完整的路徑,包括斜槓,但你只是在HTTP_HOST測試它,它將只是landed.at。你的意思是使用REQUEST_URI? (這也必須包括http://也。)

我建議這可以做到更簡潔的舊的重定向乾淨。不要拖動mod_rewrite的瑞士軍團電鋸直到你真的需要它。例如:

Redirect permanent /component/jreviews/search-results/criteria:5/query:any/jr_country:sri-lanka/order:rdate http://landed.at/itworked 
+0

嗨是的,它可以我希望爲每個國家都做到這一點,所以想要2變量動態使我所有的173個奇怪的國家很好地工作。 – landed