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

WARNING:

This information is offered "AS IS" for internal reference only. Use at your own risk.
Does AI actually understand your Miva Merchant store? Our smart 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 (updated: December 19, 2023)


THIS CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED;
THE AUTHOR DISCLAIMS ALL LIABILITY FOR ANY DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR STORE DISRUPTIONS ARISING FROM ITS USE.


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