我正在为我的网站准备重写规则。当目标网址包含“%3A”等字符时,我遇到了问题。 Apache mod_rewrite只在重写url时删除“%3”。
例如我需要重写网址
/primed-white-mdf-skirting+architrave/
到
/Products/Decorating+Interiors/Mouldings/Skirting/c/1000589?q=%3AtopSellers%3AColour%3AWhite&text=#
我为此制定了规则。这是:
RewriteRule ^primed-white-mdf-skirting\+architrave/ /Products/Decorating+Interiors/Mouldings/Skirting/c/1000589?q=%3AtopSellers%3AColour%3AWhite&text=# [R=301,L,NE]
所以重写传递给:
/Products/Decorating+Interiors/Mouldings/Skirting/c/1000589?q=AtopSellersAColourAWhite&text=%23
为什么会这样?请帮忙
答案 0 :(得分:1)
您需要转发%
,否则%3
被视为back-reference
中被捕获群组的RewriteCond
:
RewriteRule ^primed-white-mdf-skirting\+architrave/ /Products/Decorating+Interiors/Mouldings/Skirting/c/1000589?q=\%3AtopSellers\%3AColour\%3AWhite&text=# [R=301,L,NE,QSA,NC]