我想从URL中删除字符串:
http://www.example.com/wp/post-id/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+my-feed-example+%28feedexample.com+escape+this+string+now%29&utm_content=FeedBurner
自:
http://www.example.com/test/post-number/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+my-feed-example+&utm_content=FeedBurner
我想删除这个字符串:
%28feedexample.com+escape+this+string+now%29
post-id
超过 1000(帖子),所以我无法手动重定向 (301) 我的所有链接。
可能吗?以及如何?
通过httpd.conf
启用mod_rewrite
和.htaccess
,然后将此代码放在.htaccess
DOCUMENT_ROOT
目录下:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}'s/+(wp/post-id/'?.*?utm_campaign=.*?)'%28feedexample'.com'+escape'+this'+string'+now'%29([^'s]+)'s [NC]
RewriteRule ^ /%1%2 [L,R=301,NE]