$_GET中具有转义的&符号的php – htaccess重写规则失败

前端之家收集整理的这篇文章主要介绍了$_GET中具有转义的&符号的php – htaccess重写规则失败前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我遇到一个get参数与htaccess重写规则相结合的问题.
下面是urlencode()的链接;重写规则我用来重定向到index.PHP,最后是index.PHP上的一个print_r($_ GET).
您可以看到,urlescaped&符号不是变量static的值的一部分,而是与我的期望相反,被解释为变量分隔符.为什么?

初始链接

<a href="static/Game-Tech-%26-Arts-Lab">link</a>

的.htaccess:

RewriteRule ^static/(.*)$/index.PHP?static=$1 [L]

index.PHP文件

Array ( [static] => Game-Tech- [-Arts-Lab] => )
啊好吧.有趣.似乎有一个特殊的解决方案来保持&符号特别逃脱.使用 [B] flag for Rewriterules.
RewriteRule ^static/(.*)$/index.PHP?static=$1 [L,B]

当内插$1占位符时,这应该是urlencode特殊字符.它只适用于Apache 2.2,但我相信.

找到几个参考文献:

> http://www.dracos.co.uk/code/apache-rewrite-problem/
> mod_rewrite with question marks and ampersands (with PHP)
> http://www.mediawiki.org/wiki/Manual:Short_URL/Ampersand_solution

原文链接:https://www.f2er.com/php/140144.html

猜你在找的PHP相关文章