& htaccess 中的符号问题
我当前的网址是
categories_name.php?cname=at&t
这样重写的网址。
carriers/at&t
这是 htaccess 网址。
RewriteRule ^carriers/(.*)$ categories_name.php?cname=$1 [L]
上面的网址适用于所有情况,就像
categories_name.php?cname=all-tel
变量(at&t)有“&”时 一样符号然后出现问题。那么htaccess url怎么写呢?
my current url is
categories_name.php?cname=at&t
rewritten url like this.
carriers/at&t
this is htaccess url.
RewriteRule ^carriers/(.*)$ categories_name.php?cname=$1 [L]
above url is working for all like
categories_name.php?cname=all-tel
when variable(at&t) has '&' symbol then problem occuring. so how to write htaccess url?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用 B 标志进行反向引用转义:
Try it with the B flag for backreference escaping:
&
是查询字符串中不同参数之间的分隔符。因此,at&t
必须像这样进行 urlencode:at%26t
否则 PHP 会将其视为有两个参数:
cname
和t
&
is a separator between different arguments in the querystring.at&t
must therefore be urlencoded like this:at%26t
otherwise PHP will see it as if you had two arguments:
cname
andt