Htaccess - 条件匹配时丢弃部分URL

时间:2016-11-23 20:02:10

标签: .htaccess mod-rewrite url-rewriting

我需要删除?mfp =(及其后的任何内容),前提是URL中包含/ designs /。例如,这些..

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

..将成为:

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]

..将保持不变(因为它没有/设计/在URL中)。

谢谢!

1 个答案:

答案 0 :(得分:1)

您可以在网站根目录中使用此规则作为第一条规则.htaccess:

  <property>
    <name>yarn.resourcemanager.store.class</name>
    <value>org.apache.hadoop.yarn.server.resourcemanager.recovery.ZKRMStateStore</value>
  </property>
目标URI末尾的

RewriteEngine On RewriteCond %{QUERY_STRING} ^mfp= [NC] RewriteRule ^designs/ %{REQUEST_URI}? [L,NC,R=301,NE] # your remaining rules 将从原始URI中删除任何查询字符串。