How to redirect HTTP to https all pages using htaccess

Problem: Today’s is trained to SSL certificate for websites without SSL certificates visitor website look like simple and insecure. your website will show insecure to the visitors. Therefore, using an SSL-encrypted connection for safety. It becomes very important to redirect from HTTP to HTTPS.

Solution: Edit .htaccess in cPanel File Manager or FTP

Step: 1 Login to cPanel
Step: 2 Files > File Manager > Document Root for:    
Step: 3 Now select the domain name you want to access
Check "Show Hidden Files (dotfiles)"
Click "Go"
Step: 4 After a new tab or window opens, look for the .htaccess file.

Step: 5 Right clicks on the .htaccess file and click on "Code Edit" on the menu.

Step: 6 A dialogue box may pop up asking about encoding. Click "Edit" button to continue.

Step: 7 Edit the .htaccess file

Step: 8 "Save Changes" when done.

Redirecting HTTP to HTTPS All inner page and home page.

Add the following code in your .htaccess.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>

Test your website to make sure it is done correctly if In case there is a showing any error then restore to the previous code and try again. Then click “Close” to close the window.

Thanks for your reading this article, if this article is helpful for your project. So please comment on the same and share your friend’s circle.

Please follow and like us:
error

Leave a Reply

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