.htaccess redirect: http://domain.com will not redirect to https://www.domain.com

I’m having a problem with some .htaccess rules, the website is on WordPress and is using the following rules

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

When someone visits domain.com or www.domain.com or domain.com/* it works fine, it redirects to https://www.domain.com. But when I visit https://domain.com it will not redirect to the url mentioned above.

Related posts

Leave a Reply