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

Popular Posts

This is a SAMPLE TESTING MESSAGE sent through Cell Broadcasting System by Department of Telecommunication

Google doodle celebrates Colombia Independence Day 2023

Here's a comparison of PHP and Python syntax in a table format