& htaccess 中的符号问题

发布于 2024-09-02 21:55:52 字数 392 浏览 3 评论 0原文

我当前的网址是

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

無心 2024-09-09 21:55:52

尝试使用 B 标志进行反向引用转义

RewriteRule ^carriers/(.*)$ categories_name.php?cname=$1 [L,B]

Try it with the B flag for backreference escaping:

RewriteRule ^carriers/(.*)$ categories_name.php?cname=$1 [L,B]
葬シ愛 2024-09-09 21:55:52

& 是查询字符串中不同参数之间的分隔符。因此,at&t 必须像这样进行 urlencode:at%26t
否则 PHP 会将其视为有两个参数:cnamet

& 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 and t

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文