Miva Merchant Development by Scot's Scripts

HTACCESS: Better way to force HTTPS and WWW

Miva Knowledge Base
HTACCESS: Better way to force HTTPS and WWW
Important Notice: This information is for internal reference only. Use at your own risk.
Does Google actually understand your Miva Merchant store? Our JSON-LD schema generator makes sure it does. Contact us to get started. (more info)

HTACCESS: Better way to force HTTPS and WWW

Scot Ranney • December 19, 2023


htaccess www https

This is the better way to force www and https.
The miva way of combining it doesn't work right:

RewriteEngine On
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
# [NC] is a case-insensitive match
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


https://www.scotsscripts.com/mvblog/htaccess-better-way-to-force-https-and-www.html

mvkb_htaccess