You are currently viewing How to redirect users from HTTP to HTTPS using htaccess?

After the SSL of your website has been generated, you will need to redirect your visitors from non-secure HTTP to HTTPS version. Here, we will show you how to do this using the .htaccess file.

After logging in to cPanel, go to file manager > public_html You will see your website files here.

By default, the .htaccess files are hidden. You can view the hidden files on your cPanel account by clicking on Settings at the top https 1 1024x502 1

and Check the ” Show Hidden Files” Checkbox then click “Save“.

Now you can create a .htaccess file by clicking on this New File Icon Give the name .htaccess make sure to start the name with (.). Click “Create New File” https 2

If you already have a htaccess file here, you do not need to create a new one. Now select the htaccess file, click on the “Edit” button from the top section. Then click on the “Edit” button again on the top button to continue, a new window will open.

On the bottom of the document, paste the following code:

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

Keep in mind that the RewriteEngine ON command should not be present on the file more than one time.

RewriteCond and RewriteRule command should be directly under the RewriteEngine command as given above.

Now save the document and exit.

Your website should now redirect from the HTTP version to HTTPS automatically.

If you are still seeing an SSL issue on WordPress, installing Really Simple SSL plugin on WordPress should resolve the issue.

How To Replace WordPress Core File?

এই কনটেন্ট বাংলায় পড়ুন: কিভাবে .htaccess ব্যবহার করে HTTP থেকে HTTPS রিডাইরেক্ট করবেন?