Nginx redirect all http to https
In this tutorial, How to use nginx redirect all http to https. All traffic http redirect to https for your website.
How to do it.....
For example, nginx.conf file for your website
How to do it.....
For example, nginx.conf file for your website
server {Note: Using $host instead of $server_name to according to block your server.
listen 80;
listen [::]:80;
if ($host = www.huuphan.com) {
return 301 https://$host$request_uri;
}
if ($host = huuphan.com) {
return 301 https://$host$request_uri;
}
server_name www.huuphan.com huuphan.com;
return 444;
#return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.huuphan.com huuphan.com;
access_log off;
error_log /path/to/logs/error.log;
root /path/to/webroot;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$args;
index index.html index.htm index.php;
}
}
Comments
Post a Comment