首页 > 我的文章 > PHP开发 > nginx > Apache Rewrite解决问号匹配的写法

Apache Rewrite解决问号匹配的写法

浏览:825 编辑:绿萝 来源:绿萝
Apache Rewrite解决问号匹配的写法
把 /abc?id=123  =>  /def.php?id=123 的写法:

RewriteEngine on
RewriteCond %{QUERY_STRING} ^id=(.+)$
RewriteRule ^/abc$ /def.php?sid=%1 [L]

RewriteRule 不会去匹配 ? 后面的字符串,需要用RewriteCond来匹配
参考:http://lists.apple.com/archives/web-dev/2006/Mar/msg00005.html