【发布时间】:2020-07-07 03:26:35
【问题描述】:
我正在尝试使用 mod_rewrite 重写 URL,但保留方括号,因为它是脚本需要处理的:
RewriteRule ^(order|cart)/([0-9]+)/([0-9]+)/?$ /cart?a=add&pid=$2&addons\[$3\] [L,NE]
不幸的是,上面的 URL 被翻译如下:
从:https://example.com/order/1/5 到 https://example.com/cart?a=add&pid=1&addons%5B7%5D=
这是我需要的 URL 结果:
从https://example.com/order/1/5 到https://example.com/cart?a=add&pid=1&addons[5]
我需要方括号 [$3] 在 URL 中保留为方括号,而不是在 mod_rewrite 中更改为转义字符 %5B 和 %5D。不,添加反斜杠并不能解决这个问题。我还尝试了“B”标志和其他标志。
有什么帮助吗?
谢谢!
【问题讨论】:
-
您的预期结果是什么?请添加。
-
@Mandy8055 刚刚编辑添加
-
网址中不能使用标点符号? index.html 中的点呢? ;-)
标签: regex apache mod-rewrite