mardi 28 avril 2015

What is the most efficient, safest and ultimately best be way of forcing WWW & HTTPS (SSL) on a specific domain, entire site & specific folder

What is the most efficient, safest and ultimately best be way of forcing WWW & HTTPS (SSL) on a specific domain, entire site & specific folder.

I'm essentially looking for three rewrite rules

  • Spesific Domain (exampledomain.com)
  • Spesific Folder (/testfolder/)
  • Entire Website (All contents within public_html)

Here are a bunch of rules that I've gathered from around the internet but this is only a small portion of what's listed here and there...

Some of these must have negative side effects/downsides.

##Rule 1
RewriteCond %{SERVER_PORT} 80 [OR]
RewriteCond %{HTTP_HOST} ^exampledomain.com
RewriteRule ^(.*)$ http://ift.tt/1P4zfRF [L,R=301]

##Rule 2
RewriteCond %{HTTP_HOST} ^exampledomain\.com [NC]
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ http://ift.tt/1P4zfRF [R,L]

##Rule 3
RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} !^www\.exampledomain\.com$ [NC]
RewriteRule ^ https://www.exampledomain.com%{REQUEST_URI} [R=301]

##Rule 4
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ http://ift.tt/1P4zfRF [R,L]

##Rule 5
RewriteCond %{HTTP_HOST} ^exampledomain\.com$ [OR]
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ http://ift.tt/1P4zfRF [R,L]

##Rule 6
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.%1/$1 [R=301,L]

##Rule 7
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

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

Aucun commentaire:

Enregistrer un commentaire