MyBB Community Forums

Full Version: Force https://www.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to force https://www. in front of my url. 
My .htaccess in the root directory looks like this 

RewriteEngine On 

# for subdomains
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^(www\.)?amethystcheats\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.|)(.*)$ [NC]
RewriteRule ^.*$ https://%1%{REQUEST_URI} [R,L]

# for main domains
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} ^amethystcheats\.com$ [NC]
RewriteRule ^.*$ https://www.amethystcheats.com%{REQUEST_URI} [R,L]

This works, it forces https://www. in front of the URL but when you load up the site it either say's
"To many redirects", Or some hosting error page from cloudflare and when I visit a sub domain like
domain.com/forums it only forces the www. not https://www.

I have tried many variations of this .htaccess code but the all have the same or some other errors

Regards,
Finn

Uff, I fixed it now, I just added a page rule rule in cloudflare and removed the .htaccess code,
If anyone is having the same problem while using cloudflare read this

https://support.cloudflare.com/hc/en-us/...-HTTPS-SSL-
Try this
RewriteCond %{HTTPS} off
RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [R,L]

instead of
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} ^amethystcheats\.com$ [NC]
RewriteRule ^.*$ https://www.amethystcheats.com%{REQUEST_URI} [R,L]


Also don't use same htaccess file on subdomains as subdomains have different directory path and uses different htaccess file.