URL重写多个规则
我花了一些时间学习如何重写并取得了成功,但似乎无法克服这一点。我有一个网站,其网址如 www.domain.com/bystate.php?s=Massachusetts,我想将其更改为 www.domain.com/Massachusetts,我使用以下规则执行此操作。
RewriteRule ^([a-zA-Z-/]+)$ bystate.php?s=$1
现在的问题是,用户在该页面中选择一个城市后,需要将其定向到 www.domain.com/Massachusetts/west -newburyport
我一直在努力让它发挥作用,但它似乎停在第一条规则上,因为它满足条件。我尝试将第二条规则放在第一条规则之上,但它不起作用。我还尝试添加一个单词“目录”来尝试让它发挥作用,同样什么也没有。
我做错了什么?这就是我所在的地方。
RewriteRule ^([a-zA-Z-/]+)$ bystate.php?s=$1 RewriteRule ^([a-zA-Z-/]+)/([a-zA-Z-/]+)$ bycity.php?s=$1&c=$2
I have spent some time learning how to do rewrites and have had success with it but cannot seem to get past this. I have a site that will have a url like www.domain.com/bystate.php?s=Massachusetts that I want to change to www.domain.com/Massachusetts, I did this with the following rule.
RewriteRule ^([a-zA-Z-/]+)$ bystate.php?s=$1
Now the probles is once in that page the user chooses a city and needs to be directed to www.domain.com/Massachusetts/west-newburyport
I have been trying to get this to work but it seems to stop at the first rul because it meets the conditions. I tried putting the second rule on top of the first and it didnt work. I also tried adding in a word 'directory' to try and get this to work, again nothing.
What am I doing wrong? Heres where I am.
RewriteRule ^([a-zA-Z-/]+)$ bystate.php?s=$1
RewriteRule ^([a-zA-Z-/]+)/([a-zA-Z-/]+)$ bycity.php?s=$1&c=$2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
应该可以正常工作吗?
should work just fine?!