C
C
Creatori2021-05-30 16:35:10
PHP
Creatori, 2021-05-30 16:35:10

How to add redirect exceptions in htaccess?

Help with htaccess redirect please. It is necessary that everyone except my ip address and search robots be redirected. Here's a design that doesn't work. That is, the redirection itself works, only it also throws me to another site.


RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^1.2.2.1$
RewriteCond %{HTTP_USER_AGENT} !(YandexBot|Googlebot|Bingbot|Slurp|DuckDuckBot|Baiduspider|Mail.Ru)
RewriteCond %{HTTP_HOST} ^site1\.ru$ [NC]
RewriteRule ^(.*)$ site2.ru/$1 [L,R=301]

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question