[英]Is there anyway to write 1 single rule to redirect multiple dynamic URLS
嘿,我到處搜尋此答案的每個人,但只能找到分別重定向每個URL的方法。
我的舊網站網址是這樣的:
www.domain.com/show_detail.php?item=item_description_of_various_lengths
新網址如下所示:
www.domain.com/shop/brands/titan/item_description_of_various_lengths/
現在,我知道如何以1比1的方式重定向它們。 我使用以下代碼:
RewriteCond %{QUERY_STRING} ^item=item_description_of_various_lengths$ [NC]
RewriteRule show_detail.php http://www.domain.com/product-category/paint-spraying/hvlp-fine-finish/item_description_of_various_lengths/? [R=301,L]
一切正常,但是寫了大約200個之后,我只是想知道是否存在一種方法,可以將以show_detail.php開頭的所有頁面重定向到我的主頁,並稱之為一天。 甚至更好的1條規則,將它們全部重定向到一個搜索頁面,該頁面會自動搜索“ item_description_of_various_Lengths”短語。
您可以使用正則表達式catpure組動態獲取項目的值
RewriteCond %{QUERY_STRING} ^item=([^&]+)$ [NC]
然后用%1替換description_of_v_length 嗎? 在目標網址中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.