How to Redirect http to https requests for all Webpages

After the addition of the SSL certificate on your domain name, very next issue you may face is with broken http webpages. Due to some issues, your webpage may not come with https. So in this case what we have to do is to redirect all the http request to https.

Sometimes the issue is because of the cached webpage data. The http url gets automatically loaded when the user directly types the url.

Another case is some assets loaded in that page is having HTTP URLs. The second case can cause the webpage showing the brocken page or safety issue messages.

How to automatically redirect http to https

The http to https redirection is a very easy task that can be done by modifying the .htaccess file.

You can find the .htaccess file in the root folder of your website.


If you are not able to find it try – show all hidden files in – file manager Settings. Or else still you cannot find create a new file named: .htaccess

You can add the below piece of code in your .htaccess file to enable the redirection.

RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
  • After copy pasting the above code Save the .htaccess file.
  • Now try loading your url in the web browser.

Case 2:

If you are already having some contents in your htaccess file with,

RewriteEngine On
.....
....
...

Then you dont need to paste RewriteEngine On again, you can append the other two lines (given below) to the existing RewriteEngine.

RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Example is here:

Hope this had helped you in redirecting all the requests to you webpage to https. If still you face any issues with the redirection you can ask in comments below.

Tags:
automatic http to https for webpages - redirecting to https - htaccess code for easy redirection - editing existing htaccess for ssl - ssl not working fix - bluehost - inmotion - asmallorange- ssl issues- hostagator- bigrock ssl solution- resolve ssl not missing issues in webpages - godaddy - wordpress http to https https - boostrap website https - cloudflare https solution - comodo ssl not working - fix https - drupal - html5 https - dynamic websites - https - static webpages - single page sites https redirection automatic

You May Also Like

About the Author: Sreeraj Melath