XF 1.5 Proper redirection rules, www and force SSL

Hey guys I recently implemented ssl on my site and I'm trying these rewrite rules:

I've read that this rule is the preferred one by this community:
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
But this one seems to work:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://www.site.com/$1 [L,R=301]
If I use the first one I can access the site with www and without www, which seems to create duplicate content. (I DON'T KNOW WHY IT'S RECOMMENDED BY THE WAY)
Apparently,the second one works to force www and SSL, but I'm not sure..

Should I use a different redirection rule like this one:

RewriteCond %{HTTP_HOST} !^www\.
   RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

   RewriteCond %{SERVER_PORT} 80
   RewriteRule ^(.*)$ https://www.site.net/$1 [R,L]
Which redirection rule is better?
Last edited:


XenForo moderator
Staff member
Thanks Brogan, this rewrite rule seems to do the job:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://www.mysite.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^mysite\.com$ [NC]
RewriteRule ^(.*)$ https://www.mysite.com/$1 [L,R=301]
So https://mysite.com , as well as both HTTP URLs (http://mysite.com and http://www.mysite.com) all redirect to https://www.mysite.com

It redirects straight from A --> B, not A --> C --> D --> B

You can use this tool to check:

Last edited: