我真的被困在一个重写规则,不知道是否有人可以提供帮助。
I am really stuck on a rewrite rule and wonder if anyone can help.
我是从数据库中提取数据,并作为一个实例字段名我用有时也有2个字的中间有空隙。我用这个很多的网站,但在url我想用一个取代的空间 - 因为我用这个字段作为变量来确定我想拉记录
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.
所以我需要把俱乐部/ premier联赛/曼城/
so i need to turn clubs/premier league/manchester city/
到
俱乐部/ premier联赛/曼彻斯特城市/
clubs/premier-league/manchester-city/
在此先感谢
理查德
你能在你的.htaccess尝试这条规则:
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]