【发布时间】:2017-01-19 17:12:46
【问题描述】:
我需要创建重定向:
www.mysite.com/out/cars/ 到 https://cars.example.com/?aid=123(不工作)
RewriteCond %{THE_REQUEST} /out/cars [NC]
RewriteRule ^ https://cars.othersite.com/?aid=123 [NE,L,R=302]
www.mysite.com/out/cars/volvo/ 到https://cars.example.com/volvo/?aid=123(有效)
RewriteCond %{THE_REQUEST} /out/cars/([^/]+) [NC]
RewriteRule ^ https://cars.othersite.com/%1/?aid=123 [NE,L,R=302]
www.mysite.com/out/cars/volvo/vagon/ 到https://cars.example.com/volvo/vagon/?aid=123(有效)
RewriteCond %{THE_REQUEST} /out/cars/([^/]+)/([^/]+) [NC]
RewriteRule ^ https://cars.othersite.com/%1/%2/?aid=123 [NE,L,R=302]
www.mysite.com/out/bikes/ 到 https://bikes.example.com/?aid=123(不工作)
RewriteCond %{THE_REQUEST} /out/bikes [NC]
RewriteRule ^ https://bikes.othersite.com/?aid=123 [NE,L,R=302]
www.mysite.com/out/bikes/suzuki/ 到 https://bikes.example.com/suzuki/?aid=123(不工作)
RewriteCond %{THE_REQUEST} /out/bikes/([^/]+) [NC]
RewriteRule ^ https://bikes.othersite.com/%1/?aid=123 [NE,L,R=302]
www.mysite.com/out/bikes/suzuki/volusia 到https://bikes.example.com/suzuki/volusia/?aid=123(有效)
RewriteCond %{THE_REQUEST} /out/bikes/([^/]+)/([^/]+) [NC]
RewriteRule ^ https://bikes.othersite.com/%1/%2/?aid=123 [NE,L,R=302]
www.mysite.com/out/atv/bmw/black/big/best/ 到https://atv.example.com/bmw/black/big/best/?aid=123(有效)
RewriteCond %{THE_REQUEST} /out/atv/([^/]+)/([^/]+)/([^/]+)/ [NC]
RewriteRule ^ http://atv.example.com/%1/%2/%3/?aid=123 [NE,L,R=302]
问题是,有些规则有效,但不是全部。我猜他们会以某种方式干扰,但我试图改变我能做的,但没有 100% 有效:(
例如会发生这样的事情:
www.mysite.com/out/bikes/suzuki/
重定向到:
https://bikes.example.com/suzuki/%20http/?aid=123
等等。 :(
有人可以帮忙吗?非常感谢您!
【问题讨论】:
标签: php regex .htaccess redirect