# BEGIN BizBudding Inc
# revised 07/05/2018, @dws122
# these rules force SSL, support cPanel's autossl with Let's Encrypt, and set the preferred domain
# be sure to replace example.com with your FQDN
# we default to non-www
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Enforce https SSL/TLS
RewriteCond %{HTTPS} off
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{REQUEST_URI} !^/\d+\.BIN_AUTOSSL_CHECK_PL__\.\w+\.tmp$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/
# note, if force www then add it here too
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
# Now that we have SSL running, enfore HSTS
#
# When the web server sends this header, any browser that accesses the site over HTTPS
# will be unable to access the unsecured HTTP site for the specified length of time
# (in this case, 31,536,000 seconds, or one year). Therefore, as soon as you enable HSTS,
# you should not stop using SSL on your site. If you do, returning visitors will be unable
# to access your site.
#
#Header set Strict-Transport-Security "max-age=31536000" env=HTTPS
# Enforce non-www rules on the domain
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteCond %{REQUEST_URI} !^/\d+\.BIN_AUTOSSL_CHECK_PL__\.\w+\.tmp$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
# Enforce www rules on the domain
#RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
#RewriteCond %{REQUEST_URI} !^/\d+\.BIN_AUTOSSL_CHECK_PL__\.\w+\.tmp$
#RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/
#RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
# for date based urls
#RewriteRule ^([0-9]+)/([0-9]+)/(.*)$ https://example.com/$3/ [R=301,NC,L]
# for date based urls ending in .html
#RewriteRule ^([0-9]+)/([0-9]+)/(.*)\.html$ https://example.com/$3/ [R=301,NC,L]
# for urls ending in .html
#RewriteRule ^(.*)\.html$ https://example.com/$1/ [R=301,NC,L]
</IfModule>
# END BizBudding