开发者

htaccess rewrite replace space with -

I am really stuck on a rewrite rule and wonder if anyone can help.

I am pulling data from a database, and as an example the field "name" i use sometimes has 2 words in with a space between. I use this alot on the site but in the url i want to replace the space with a - as i use this field as a variable to determine the record i want to pull.

so i need to turn clubs/premier league/manchester ci开发者_如何学JAVAty/

into

clubs/premier-league/manchester-city/

thanks in advance

richard


Can you try this rule in your .htaccess:

RewriteEngine on
RewriteRule ^clubs/([^\s]+)\s([^\s]+)/([^\s]+)\s([^\s]+)/$ /clubs/$1-$2/$3-$4/ [R=302,NC,L]
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜