Answer the question
In order to leave comments, you need to log in
Why might nginx redirect not work?
server {
listen 111.111.111.111:443 ssl http2;
server_name site1.com;
ssl_certificate /etc/letsencrypt/live/site1.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/site1.com/privkey.pem;
location / {
return 301 https://site2.com$request_uri;
}
location /secure/ {
try_files $uri =404;
}
}
server {
listen 111.111.111.111:80;
server_name site1.com;
return 301 http://site2.com$request_uri;
}
Answer the question
In order to leave comments, you need to log in
If you write site1.com in the address bar, it will redirect to site2.com.
If you write https://site1.com in the address bar, it will redirect to https://site2.com.
All this is written in your rules. Learn to read them, and read the documentation, and not copy the configs from the left sites, then there will be no such questions)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question