L
L
lemast2018-08-30 07:54:42
Nginx
lemast, 2018-08-30 07:54:42

How to make redirects with https enabled on nginx?

Good morning comrades!
There is a config for nginx, the fact is that over http - all redirects work as they should. I connected an SSL certificate to the site - the site works via https, but redirects stopped working, in particular, there is no redirection from https://site.ru/index.php to https://site.ru , as well as from https://site .ru/page/ on https://site.ru/page (without slash)
server {
listen 777.777.777.777:80;
server_name site.ru www.site.ru;
error_log /var/log/httpd/domains/site.ru.error.log error;
return 301 https://$server_name$request_uri ;
rewrite ^(.*) https://$server_name$uripermanent;
rewrite ^/(.*)/$ /$1 permanent;

location /index.php {
return 301 $ scheme://$host ;
}

try_files $uri $uri/ Nicholas ;
location Nicholas { rewrite ^/(.*)/ /$1.php last; }


location / {
proxy_pass 777.777.777.777:8080 ;
location ~* ^.+\.(html|jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|ttf|otf|webp|woff|txt|csv|rtf|doc |docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3 |mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
root /home/admin/web/site.ru/public_html ;
access_log /var/log/httpd/domains/site.ru.log combined;
access_log /var/log/httpd/domains/site.ru.bytes bytes;
expires max;
try_files $uri @fallback;
}
}

location /error/ {
alias /home/admin/web/site.ru/document_errors/;
}

location @fallback {
proxy_pass 777.777.777.777:8080 ;
}

location ~ /\.ht {return 404;}
location ~ /\.svn/ {return 404;}
location ~ /\.git/ {return 404;}
location ~ /\.hg/ {return 404;}
location ~ /\.bzr/ {return 404;}

disable_symlinks if_not_owner from=/home/admin/web/site.ru/public_html;

include /home/admin/conf/web/nginx.site.ru.conf*;
}

I would appreciate any help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lemast, 2018-08-30
@lemast

try_files $uri $uri/ Nicholas;
location Nicholas { rewrite ^/(.*)/ /$1.php last; }
Instead of Nicholas - @ url; - without space

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question