Problem
I have made the required setting under WordPress settings for my WordPress blog www.dbappweb.com to run all the pages on SSL. I made the below settings on WordPress under Settings >> General, changing the URLs from http://www.dbappweb.com to https://www.dbappweb.com.
But still, if someone tries to access the webpages without SSL then these were being accessed. I was in search of a solution which can redirect all HTTP requests to HTTPS. Finally, I found the solution and implemented it on my WordPress blog hosted on Bluehost to force SSL on all pages.
Solution
To force all the pages to use SSL i.e. forcefully redirecting all the pages from HTTP to HTTPS you need to modify the .htaccess file on Bluehost. You need to add the below lines of code in the .htaccess file.
RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Edit .htaccess file on Bluehost
- Login to Bluehost and open the cPanel
- Under the File section click on the File Manager icon.
- A pop-up File Manager Settings will be opened, select the Web Root from Directory Section and check the checkbox against Show Hidden Files under Preferences.
- I will open the public_html directory of your webroot, try to find the .htaccess file in this directory. Here I was not able to find the .htaccess file because hidden files were not being shown here even after enabling the show hidden files.
- To show hidden files I have added &showhidden=1 at the end of the URL in the address bar of the browser and hit the enter button. After these hidden files are shown in the folder which can be edited.
- Select the .htaccess file and open it in Code Editor.
- Add the lines of code as given above in the starting and save the .htaccess file.
# Use PHP7.2 as default AddHandler application/x-httpd-ea-php72 .php . . #Added to force all pages on SSL RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] . . RewriteRule ^([0-9]{4})_([0-9]{1,2})_([0-9]{1,2})_archive.html$ $1/$2/ [L,R=301]
- Now all pages of your website will be forcefully redirected to HHTPS and your website will run fully on SSL.
Last Updated: August 30, 2020
Related Posts