Answer the question
In order to leave comments, you need to log in
How to redirect nginx to another site by specifying user agent?
Tell me how to register correctly in the nginx config
so that when accessing the url domen1/?reklama=1 from all user agents except bots, a 302 redirect to https://domen2/lang/home?reklama=1
is performed in the config there is such a
location ~ /?reklama= 1{
if ($http_user_agent ~ firefox) {
return 302 https://domen2/lang/home?reklama=1;
}
but it doesn't work if I remove the question mark it works, tell me how to correctly write the regular expression
Answer the question
In order to leave comments, you need to log in
map "$http_user_agent:$args" $redirect {
"~(Bot1|Bot2):reklama=1" "0";
default "1";
}
if ($redirect) {
return 302 https://domen2/lang/home?reklama=1;
}
something like this
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question