开发者

Rewrite Periods/Dots/(.) in mod_rewrite to plus (+)

开发者 https://www.devze.com 2022-12-17 05:47 出处:网络
How do I change a period/dot (.) into a plus (+) of a match using mod_rewrite? My match is #2. This is my rule so far:

How do I change a period/dot (.) into a plus (+) of a match using mod_rewrite? My match is #2.

This is my rule so far:

RewriteRule ^(.*)/(.*)-[0-9]*\.shtml$ http://kentwired.com/search/most-popular/?searchphrase=exact&searchword=$2 [L,R=301]

With my rules currently,

http://media.www.kentnewsnet.com/media/storage/paper867/news/2009/12/11/New开发者_如何学Cs/Tough.Economy.Leaves.Bodies.Unburried-3850836.shtml

becomes

http://kentwired.com/search/most-popular/?searchphrase=exact&searchword=Tough.Economy.Leaves.Bodies.Unburried

but I need

http://kentwired.com/search/most-popular/?searchphrase=exact&searchword=Tough+Economy+Leaves+Bodies+Unburried


Try this:

RewriteRule ^([^.]*)\.(.*\.shtml)$ /$1+$2 [N]
RewriteRule ^.+/([^/]+)-[0-9]*\.shtml$ http://kentwired.com/search/most-popular/?searchphrase=exact&searchword=$1 [L,R=301]
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号