我在htaccess中有这个正则表达式:
$this->admindatahelper
此网址
RewriteCond %{THE_REQUEST} .*?/out/([^/]+)/?(.*) [NC]
RewriteRule ^ http://%1.example.com/%2?aid=123 [NE,L,R=302]
返回
www.mydomain.com/out/cars/bmw/
事实上,在?aid = 123 之前总是%20HTTP / 1.0 ,无论使用 www.mydomain.com/out / 我试试:(
为什么呢?如何摆脱它?
提前谢谢!
答案 0 :(得分:1)
问题是匹配THE_REQUEST,它比你想象的要多。请改用REQUEST_URI。像这样:
RewriteCond %{REQUEST_URI} /out/([^/]+)/?(.*) [NC]
RewriteRule ^ http://%1.example.com/%2?aid=123 [NE,L,R=302]
供参考: http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritecond