NGINX редирект
Файлы с примерами редиректа для nginx
Редирект с http на https
server {
listen 80;
server_name domain.com;
root /var/www/domains/domain.com;
index index.php;
autoindex off;
# Let's encrypt
location ~ /.well-known {
root /var/www/html;
allow all;
break;
}
if ($scheme = http) {
return 301 https://$host$request_uri;
}
}
Редирект с www на без www
server {
listen 80;
server_name domain.com;
root /var/www/domains/domain.com;
index index.php;
autoindex off;
# Let's encrypt
location ~ /.well-known {
root /var/www/html;
allow all;
break;
}
if ($host ~* www\.(.*)) {
set $domain $1;
return 301 $scheme://$domain$request_uri;
}
}