Answer the question
In order to leave comments, you need to log in
How to disable redirect to https for robots.txt?
There is a site that works under nginx, the entire site redirects from http to https, but actually how to make robots.txt open in the same way via http?
If in .htaccess, it's done like this:
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/robots.txt$ [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L]
Answer the question
In order to leave comments, you need to log in
Finally decided this:
server {
listen 80;
server_name site.ru;
root /var/www/site.ru;
location ~* ^.+\.(txt|css|js|xml)$ { }
location / {
return 301 https://site.ru$request_uri;
}
}
server {
listen 80;
server_name site.ru www.site.ru;
root /var/www;
location = /robots.txt { }
location / {
return https://site.ru$request_uri;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question