W
W
weranda2018-03-08 09:38:29
htaccess
weranda, 2018-03-08 09:38:29

How to fix loopback redirect in .htaccess?

I can't figure out how to correctly configure bots to redirect by user-agent to a specific page in the .htaccess file.
Here is the code:

RewriteCond %{HTTP_USER_AGENT} yandex [NC,OR]
RewriteCond %{HTTP_USER_AGENT} mozilla [NC,OR]
RewriteCond %{HTTP_USER_AGENT} chrome [NC,OR]
RewriteCond %{HTTP_USER_AGENT} google [NC]
RewriteRule ^(.*)$ https://mysite.ru/target/

If the user-agent contains a text that matches the conditions, then we redirect the bot to the desired page, but on this page the .htaccess rules again work, and so on in a circle.
What should be written in the file so that when a bot is detected, the redirect will work on all pages except the desired one?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Epifanov, 2018-03-08
@kacheleff

Have you tried adding the L flag?
RewriteRule ^(.*)$ https://mysite.ru/target/ [L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question