mod_rewrite 为 %26

发布于 2024-09-30 03:41:33 字数 383 浏览 0 评论 0原文

我试图将像

“Lights+&+Lamps”

这样的类别名称作为参数传递,并使用我理解的重写规则

RewriteCond %{HTTP_HOST}        example.com$
RewriteRule ^/category/([^/]+)$   /showproduct.pl?category=$1 [PT]

&是一个参数分隔符,但即使我传入:

“Lights+%26+Lamps”,

我的输出也是“Lights”,

所以 mod 重写会吃掉 %26 处的所有内容,

我尝试了不同的标志,如 [NE] 和 QSA,但没有成功。

有什么想法吗?

I'm trying to pass in as a parameter a category name like this

"Lights+&+Lamps"

with this rewrite rule

RewriteCond %{HTTP_HOST}        example.com$
RewriteRule ^/category/([^/]+)$   /showproduct.pl?category=$1 [PT]

I understand & is a paramater separator, but even when I pass in :

"Lights+%26+Lamps"

My output is "Lights"

So mod rewrite is eating everything at %26

I've tried different flags like [NE] and QSA with no luck.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

我是男神闪亮亮 2024-10-07 03:41:33

我遇到了类似的问题,其中“&”(&符号)被 mod_rewrite 错误地重写了。 B 标志解决了这个问题:

B(转义反向引用) [B] 标志指示 RewriteRule 转义
应用转换之前的非字母数字字符。

它允许我提供包含“&”的文件在他们的名字中,例如此处
你需要的是这个

RewriteCond %{HTTP_HOST}        example.com$
RewriteRule ^/category/([^/]+)$   /showproduct.pl?category=$1 [B, PT]

I had similar problem where the '&'(ampersand) was incorrectly rewritten by the mod_rewrite. The B flag solved it:

B (escape backreferences) The [B] flag instructs RewriteRule to escape
non-alphanumeric characters before applying the transformation.

It allowed me to serve the files containing '&' within their name, eg here
What you need is this

RewriteCond %{HTTP_HOST}        example.com$
RewriteRule ^/category/([^/]+)$   /showproduct.pl?category=$1 [B, PT]
哽咽笑 2024-10-07 03:41:33

您可以在此之前使用另一个规则将 % 重写为 %25 吗?

Could you rewrite % to %25 with another rule before that?

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