Welcome! Log In Create A New Profile

Advanced

Re: 301 редирект http->https исключая графику и robots.txt как ?

Oleg A. Mamontov
March 23, 2015 05:30AM
On Mon, Mar 23, 2015 at 05:20:39AM -0400, anstrem wrote:
> Подскажите как правильно настроить 301 редирект сайта с http на https
> протокол, но при этом оставить доступ к robots.txt и всем графическим файлам
> по http (иначе они не будут индексироваться Яндексом) ?
>
> Пробовал вот так:
>
> server {
> listen ip;
> server_name domain.ru *.domain.ru www.domain.ru;
> location /robots.txt {
> rewrite ^ /robots.txt break;
> }
> location ~* ^.+\.(jpg|jpeg|gif|png|ico)$ {
> rewrite ^ http://$server_name$request_uri? break;
> }
> location / {
> return 301 https://domain.ru$request_uri;
> }
> }
> server {
> server_name domain.ru *.domain.ru www.domain.ru;
> listen ip:443 ssl;
> ...
>

server {
listen ip;
server_name domain.ru *.domain.ru www.domain.ru;

location / {
return 301 https://domain.ru$request_uri;
}
location ~* \.(?:ico|gif|jpeg|jpg|png)$ {
root /path/to/static;
}
location /robots.txt {
root /path/to/static;
}
}

> Сам по себе редирект с http на https работает, а вот с исключениями проблема
> :(
> При попытке открыть http:/domain.ru/robots.txt - получаю 404 Not Found
> При попытке открыть любой граф файл по http типа:
> http://domain.ru/images/image.jpg получаю - На этой странице обнаружена
> циклическая переадресация
>
> Никто не подскажет как правильно сделать такие исключения для редиректа в
> nginx ?
>
> Posted at Nginx Forum: http://forum.nginx.org/read.php?21,257548,257548#msg-257548
>
> _______________________________________________
> nginx-ru mailing list
> nginx-ru@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-ru

--
Cheers,
Oleg A. Mamontov

_______________________________________________
nginx-ru mailing list
nginx-ru@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-ru
Subject Author Posted

301 редирект http->https исключая графику и robots.txt как ?

anstrem March 23, 2015 05:20AM

Re: 301 редирект http->https исключая графику и robots.txt как ?

kemko March 23, 2015 05:24AM

Re: 301 редирект http->https исключая графику и robots.txt как ?

anstrem March 23, 2015 05:43AM

Re: 301 редирект http->https исключая графику и robots.txt как ?

Oleg A. Mamontov March 23, 2015 05:30AM

Re: 301 редирект http->https исключая графику и robots.txt как ?

anstrem March 23, 2015 05:51AM

Re: 301 редирект http->https исключая графику и robots.txt как ?

Oleg A. Mamontov March 23, 2015 06:06AM

Re: 301 редирект http->https исключая графику и robots.txt как ?

anstrem March 23, 2015 06:17AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 232
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready