Мне нужно создать перенаправления:
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 to 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
так далее. 🙁
Кто-нибудь может помочь? Заранее большое спасибо!
может быть, более простого регулярного выражения все еще будет достаточно? (выводя очевидные правила из примеров, поскольку они явно не указаны)
RewriteCond %{THE_REQUEST} .*?/out/(cars|bikes|atv)/?(.*) [NC]
RewriteRule ^ http://$1.example.com/$2?aid=123 [NE,L,R=302]
Попробуйте с:
RewriteRule ^out/cars/?$ https://cars.othersite.com/?aid=123 [NC,NE,L,R=302]
RewriteRule ^out/cars/([^/]+)/?$ https://cars.othersite.com/$1/?aid=123 [NC,NE,L,R=302]
RewriteRule ^out/cars/([^/]+)/([^/]+)/?$ https://cars.othersite.com/$1/$2/?aid=123 [NC,NE,L,R=302]
RewriteRule ^out/bikes/?$ https://bikes.othersite.com/?aid=123 [NC,NE,L,R=302]
RewriteRule ^out/bikes/([^/]+)/?$ https://bikes.othersite.com/$1/?aid=123 [NC,NE,L,R=302]
RewriteRule ^out/bikes/([^/]+)/([^/]+)/?$ https://bikes.othersite.com/$1/$2/?aid=123 [NC,NE,L,R=302]
RewriteRule ^out/atv/([^/]+)/([^/]+)/([^/]+)/?$ http://atv.example.com/$1/$2/$3/?aid=123 [NC,NE,L,R=302]