我想从网址中删除字符串:
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)我的所有链接。
有可能吗?怎么样?
答案 0 :(得分:0)
启用mod_rewrite
和.htaccess
到httpd.conf
,然后将此代码放在.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]