Help me figure out a redirection rule with the exception of the robots.txt file in .htaccess .

The site moved from http to https . Appealed to those hosting support and they wrote a redirection rule from http to https in the .htaccess file with the following content:

 RewriteEngine On RewriteCond %{HTTP:X-Forwarded-Protocol} !=https RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] 

Redirects start working. But an error was found in the control panel:

The server responds with a redirect to the request /robots.txt

Further technical support hosting said the following:

To correct the situation, you must set the correct rules for redirection with exceptions.

Help them ask

  • one
    Victoria, it is better to make an amendment to the question than to write unreadable comments - korytoff
  • @NickVolynkin so Victoria herself has already made an amendment to the question - korytoff
  • @korytoff: wow, it looks like I looked. Delete edit. - Nick Volynkin

1 answer 1

I do not understand what the problem is using the documentation ?

Google also knows a lot. Well, SO full of answers .

 RewriteEngine on RewriteCond %{REQUEST_FILENAME} !robots\.txt RewriteCond %{HTTP:X-Forwarded-Protocol} !=https RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]