How To Redirect Http To Https In Apache and Nginx – POFTUT

How To Redirect Http To Https In Apache and Nginx

Http is popular protocol used to transfer web page data like HTML, Javascript, Image etc. HTTP is used between our browser like Chrome, Firefox, Edge, Internet Explorer and server like Apache, Nginx etc. HTTPS is secure version of HTTP and recently sites transition to the HTTPS. But what is a user try to access HTTP of our web site. We can redirect HTTP web sites to the HTTPS. Below you can find redirect ways for different web servers.

Apache

Apache is very popular web server which is number 1 in internet. We can use HTTP 301 Redirect status code for this like below. But as we can see we need to enable RewriteEngine too.

Nginx

Nginx is another popular web server which gains momentum in last years. We can use following server configuration in order to redirect HTTP to HTTPS. We will use HTTP 301 Redirect status code with return option. Other part of the configuration is just example.

Leave a Reply

Your email address will not be published. Required fields are marked *

Enjoy this blog? Please spread the word :)