我的.htaccess:中有以下代码
RewriteEngine On
Options -MultiViews
Options +FollowSymlinks
RewriteBase /testUrl/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1 [L]
RewriteRule ^(.*)'/('?.*)?$ $1$2 [R=301,L]
然后我使用$_GET['page']方法捕获参数。
这项工作:
localhost/testUrl/param1/param1
这个DOES'NT工作
http://localhost/testUrl/param1/param1?newparam=test&nextparam=test1
但这是有效的:
http://localhost/testUrl/param1/param1&newparam=测试&nextparam=test1
我需要把工作作为第二个例子。。。带有/param1/param2?newparam=etc
有什么建议吗?非常感谢大家
这是因为您的重写规则不包括QSA标志开关告诉apache附加查询字符串。
RewriteRule ^(.*)$ index.php?page=$1 [QSA,L]
RewriteRule ^(.*)'/('?.*)?$ $1$2 [QSA,R=301,L]
要阅读更多关于重写mod标志的信息,请访问-http://httpd.apache.org/docs/2.4/rewrite/flags.html