2016-11-23 71 views
1

我需要刪除?mfp =(以及其後的任何內容),前提是該URL包含/ designs /。因此,例如,這些..Htaccess - 當條件匹配時丟掉URL的一部分

https://www.example.com/designs/upload-your-own/?mfp=30o-color%5B112%5D&tag=hoodies 
https://www.example.com/designs/upload-your-own/?mfp=60o-type%5B191%5D%2C30o-color%5B112%5D&tag=hoodies 
https://www.example.com/designs/upload-your-own/?mfp=manufacturers%5B43%5D%2C60o-type%5B191%5D%2C30o-color%5B112%5D&tag=hoodies 
https://www.example.com/designs/upload-your-own/?mfp=c-categories-0%5B305%5D&tag=hoodies 

..will成爲:

https://www.example.com/designs/upload-your-own/ 
https://www.example.com/designs/upload-your-own/ 
https://www.example.com/designs/upload-your-own/ 
https://www.example.com/designs/upload-your-own/ 

但這樣的:

https://www.example.com/hoodies/?mfp=c-categories-0[305],manufacturers[43],60o-type[191],30o-color[112] 

..will保持不變(因爲它沒有/設計/在URL中)。

謝謝!在目標URI結束

RewriteEngine On 

RewriteCond %{QUERY_STRING} ^mfp= [NC] 
RewriteRule ^designs/ %{REQUEST_URI}? [L,NC,R=301,NE] 

# your remaining rules 

?將剝離由原來的任何URI查詢字符串:

+0

還有,你試過嗎? – Walf

回答