Nowadays, SSL protocol is becoming more popular for webmasters who want to security through an encrypted connection their server. After install SSL, how can you redirect HTTP to HTTPS ? Oh, this post will help you.
HTTPS(Hyper Text Transfer Protocol Secure) protocol is a secure version of HTTP which can used for secure transactions of ecommerce sites, it is also make your site have good ranking in Google. In this tutorial we will show you how to redirect all traffic from HTTP to HTTPS using nginx rewrite.
In nginx.conf, just add or modify like bellow:
1 |
rewrite ^ https://$server_name$request_uri? permanent; |
When finish you will have something like this:
1 2 3 4 |
server { server_name www.example.com; rewrite ^ https://$server_name$request_uri? permanent; } |
1 |
service nginx restart |
Very easy right ? I hope this simple tip can help you 😀