How to force redirect URL from HTTP to HTTPS?
Sometimes we dont know that only SSL certificate installation is not sufficient for your website security. If someone hit url with http then server will allow them to browse without enabling https. As a result SSL will not properly utilized.
We can easily do this with the help of .htaccess file. In this tutorial i will explain how to redirect all your http request into https.
What is .htaccess?
An .htaccess
file is used for an Apache web server as a way
to configure the details of your website without altering the server
configuration files. This file begins with a period to signify that it’s
hidden within the folder. An .htaccess
file can be used to
load customized error pages (such as 404 pages), create URL redirects,
implement password-protected authentication for specific directories on
your server, and many more.
Steps to force redirect:
- Create a .htaccess file on your root directory of the project
- Copy and paste the code given below
- Save the file and check
This code will only worked for that directory which contains .htaccess file. & remember this is compatible for apache linux server.
Leave your Comment