Nginx How to redirect all http and https requests to another site.
We can redirect all http and https requests to another domain using the below script in the nginx configuration.
1. For HTTP redirection
-------
server {
listen 80;
server_name domain.com;
return 301 https://domain.com$request_uri;
}
2. For HTTPS redirection
------
server {
listen 443 ssl;
server_name domain.com;
return 301 https://domain.com$request_uri;
sl_certificate /etc/ssl/domain.com.pem;
ssl_certificate_key /etc/ssl/domain.com.key;
}

Comments
Post a Comment