Select Page

Access your website via FTP or via your server’s File Manager and search at the root of your WordPress instalation for the .htaccess file. Here you have 3 solutions to solve the same question:

How to redirect all HTTP request to HTTPS.

Before you edit the .htaccess file, I recommend to make a backup to be able to revert your changes (in case something goes wrong).

So here you go, copy and paste the code below in your .htaccess file, save it, and re-upload it.

Solution 1

1
2
3
RewriteEngine On<br />
RewriteCond %{HTTPS} off<br />
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

These lines of code will direct all HTTP requests to https://www.example.com as well as redirect https://example.com to https://www.example.com.

Solution 2

1
2
3
4
5
RewriteEngine On<br />
RewriteCond %{HTTPS} off<br />
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]<br />
RewriteCond %{http_host} ^example.com [NC]<br />
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]

Solution 3

1
2
3
4
5
6
RewriteEngine On<br />
RewriteBase /<br />
RewriteCond %{HTTP_HOST} ^domain.com$ [OR]<br />
RewriteCond %{HTTP_HOST} ^www.domain.com$ [OR]<br />
RewriteCond %{HTTPS_HOST} ^domain.com$<br />
RewriteRule ^(.*)$ "https\:\/\/www\.domain\.com\/$1" [R=301,L]

Leave a comment with what worked for you. Go ahead and share if you have a different aproach.