http to https redirection using .htaccess file

Is it possible? Yep, we can redirect the non SSL query to your website to SSL port by using .htaccess file in the website’s public folder. If the file is not there, go ahead and simply create it. This will help you to access¬†the¬†websites from a secured port(443 of apache) of we server. Please do follow the steps explained below:

1, Create/Open the file .htaccess

2, Add the following redirect rule.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

That’s it!

Is it possible to add HTTP to HTTPS redirection rule from cPanel?

Yes, it is. If you have a cPanel server, you can define the redirect rule from the cPanel of the website. Please follow the steps listed below:

1, Log into cPanel.

2, Move to “Redirects” under “Domains” tab.

redirect

3, Define rule from here;

Redirects

That’s it!

Related

1, How to disable phpinfo(); in a shared environment/hosting?
2, .htaccess rules for not executing php in images folder
3, How to prevent .htaccess file modification while running easyapache ?

Post navigation

Arunlal Ashok

Cloud Infrastructure / DevOps Engineer. I know her (Linux) since many years. Linux lover. Like to play on Linux console. I started this blog to share and discuss Linux thoughts.

Always happy for an open discussion! Write to arun (@) crybit (dot) com. Check about me for more details. About this blog and our strong members, check The team CryBit.com

Leave a Reply

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