Redirect Http to Https through .Htaccess File

ForumCategory: Cpanel Control PanelRedirect Http to Https through .Htaccess File
Ali Zaki asked 4 years ago

Hello, I have bought a domain and web hosting from Zain Hosting, I di not uploaded anything in my website, and its opening http version at this time, I dont want to upload my site at this time, but I want to redirect my URL to HTTPS SSL version, Please provide me code that I put in my htaccess file to enable redirection.

1 Answers
Zain Hosting answered 4 years ago

Hi, thank you so much for choosing us,

its an easy process of rediret your site HTTP to HTTPS through .htaccess file, I am providing you the steps below!

1: Go to your Cpanel file manager > find your htaccess file, if not found then show hidden files option in your file manager.

2: now right click on .htaccess file and click on edit.

3: Paste this code in your .htaccess file,

RewriteEngine On

RewriteCond %{HTTPS} !on

RewriteCond %{REQUEST_URI} !^/[0-9]+..+.cpaneldcv$

RewriteCond %{REQUEST_URI} !^/.well-known/pki-validation/[A-F0-9]{32}.txt(?: Comodo DCV)?$

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

Now save your .htaccess file and SSL redirections is enabled, when you or your visitors open your site with http it will be redirected to https version automatically.

Note: If you dont find .htaccess file in your cpanel file manager then you can create a new file with the name of .htaccess.

Your Answer

Accepted file types: txt, jpg, pdf

Add another file