1

我想从 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)我的所有链接。

是否可以?如何 ?

4

1 回答 1

0

启用mod_rewrite.htaccess通过httpd.conf然后将此代码放在您.htaccessDOCUMENT_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]
于 2013-09-23T16:02:39.170 回答