【发布时间】:2016-01-27 11:02:22
【问题描述】:
到目前为止我已经学会了RewriteRule ^([^/]*)/$ index.php?page=$1
问题1:如何解析url参数,因为它们在某个点之后?
例如我希望此页面 http://example.com/index.php?page=X&id=2&err=10 显示为 http://example.com/X/?id=2&err=10。鉴于参数id 或err 必然不存在。他们可能会或可能不会与其他人一起出现。
问题2:对于某些特定页面假设page=A或page=B,如果id存在,也会有第三个参数。
例如我希望此页面 http://example.com/index.php?page=A&id=10&name=Abe 显示为 http://example.com/A/Abe/10/ 和 http://example.com/index.php?page=A&id=10&name=Abe&err=101 显示为 http://example.com/A/Abe/10/?err=101
16 年 1 月 30 日编辑
好的。经过大量搜索,我发现它可以通过使用{QUERY_STRING} 来实现。但是当我将RewriteRule ^([^/]*)$ index.php?page=$1&%{QUERY_STRING} [NC,L] 放在我的htaccess 中时,我的Ajax 就失控了。我希望这项工作仅适用于 index.php 而没有其他页面。
【问题讨论】: