Apache:NE标志(无转义)不在mod_rewrite的RewriteRule中工作

Apache:NE标志(无转义)不在mod_rewrite的RewriteRule中工作,apache,mod-rewrite,url-rewriting,urlencode,urldecode,Apache,Mod Rewrite,Url Rewriting,Urlencode,Urldecode,我有这样一个URL: http://www.sample.com/do/example/v1/abcd 我想将其重定向到: http://sub.sample.com/some/test/do/example/v1/abcd 因此,我创建了一个.htaccess文件,并使用重写规则来执行此操作: RewriteCond %{HTTP_HOST} ^(www\.)?sample\.com$ RewriteCond %{REQUEST_URI} ^/do/(.*)$ RewriteRule ^(

我有这样一个URL:

http://www.sample.com/do/example/v1/abcd
我想将其重定向到:

http://sub.sample.com/some/test/do/example/v1/abcd
因此,我创建了一个
.htaccess
文件,并使用重写规则来执行此操作:

RewriteCond %{HTTP_HOST} ^(www\.)?sample\.com$
RewriteCond %{REQUEST_URI} ^/do/(.*)$
RewriteRule ^(.*) http://sub.sample.com/some/test/do/%1
一切正常,直到“abcd”更改为具有%2B转义字符的“PjX7%2Bj69”。因此,使用此URL:

http://www.sample.com/do/example/v1/PjX7%2Bj69
我得到:

404 Not Found | The requested URL do/example/v1/PjX7+j69 was not found on this server.
我们注意到,Apache将“PjX7%2Bj69”参数更改为“PjX7+j69”。因此,我使用
NE标志
禁用解码:

RewriteRule ^(.*) http://sub.sample.com/some/test/do/%1 [NE]
但它不起作用

如何防止Apache URL解码?

这不是它的目的

无论如何,这些路径应该是等价的,因为您应该在子域中解码这些序列。如果你真的不能纠正这一点,我认为这是真正的问题,你可以改为使用原始的、未编码的URL:

RewriteCond %{HTTP_HOST} ^(?:www\.)?sample\.com$
RewriteCond %{THE_REQUEST} ^\S+\s+/do/(.*)\s
RewriteRule ^ http://sub.sample.com/some/test/do/%1 [R,END]