I need to write two redirects:
- From
https://site.ru/dveri
tohttps://anothersite.ru/dveri-iz-dereva/
- From
https://site.ru/dveri?start=14
tohttps://anothersite.ru/blog/
I wrote two rules in htaccess:
#1
RewriteCond %{THE_REQUEST} s/+dveri[?s/] [NC]
RewriteRule ^ https://anothersite.ru/dveri-iz-dereva/ [L,R=301]
#2
RewriteCond %{THE_REQUEST} s/+dveri[?s/] [NC]
RewriteRule ^.*$ https://anothersite.ru/blog/? [L,R=301]
Result:
link https://site.ru/dveri
redirects correctly to https://anothersite.ru/dveri-iz-dereva/
link https://site.ru/dveri?start=14
redirects incorrectly to https://anothersite.ru/dveri-iz-dereva/?start=14
3
Answers
My experienced collegue helped me with this:
The two rules you wrote are the same. Try this for the second
If these directives are placed at the top of the root
.htaccess
file then these can be simplified to: