我怎样才能使用mod_rewrite删除后的一切? (问号)在一个URL?
例如:http:// 127.0.0.1/ALL_FILES.php?test=1 mod_rewrite之后:http:// 127.0.0.1/ALL_FILES.php
对于PHP来说,这意味着$ _GET超级全局将始终为空。
谢谢。
从mod_rewrite文档引用:
模式不会与查询string匹配。 相反,您必须使用带有{QUERY_STRING}variables的RewriteCond
有些东西是:
RewriteCond %{QUERY_STRING} . RewriteRule ^/index.php /index.php? [L,R]
应该做你需要的。 如果你不关心显示给用户的是什么,而只是传递给php的东西,你可以省略R标志。
RewriteCond %{QUERY_STRING} .+ RewriteRule ^(.*)$ /$1? [R=301,L]