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:
Code:
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

But this one seems to work:
Code:
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:

Code:
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:
Thanks Brogan, this rewrite rule seems to do the job:

Code:
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:

https://www.linksspy.com/seo-tools/free-seo-ssl-scan/
 
Last edited:
Top Bottom