2
我终于决定钻研正规表达的精彩世界。我的Regex/htaccess语法是否正确?
基本上我的目标是
浏览器发送:
http://example.com/search/Bombay
阿帕奇转换成该:
http://example.com/search/?city=Bombay
我的规则的尝试是这样的:
RewriteRule ^search/([^/.]+)/?$ search/?city=$1
这是正确的方法吗?有没有什么好的地方可以更多地了解Regex?
在此先感谢
你测试了你目前的模式吗?它应该工作正常。一定要启用mod_rewrite:'RewriteEngine on'和'Options + FollowSymLinks'。 – Bojangles
不要在下面加上'[L,QSA]'标志:'RewriteRule^search /([^/.]+)/?$ search /?city = $ 1 [L,NC,QSA] ' – anubhava
[http://www.regular-expressions.info/](http://www.regular-expressions.info/),[Apache Mod_Rewrite Documentation](http://httpd.apache.org/docs/current /mod/mod_rewrite.html) –