- 233 views
Add Rules at the end of the file
This part is easy, to redirect your Drupal 7 installation to non-WWW SSL enabled website, use the snipplet below.
RewriteCond %{HTTP_HOST} ^www\.(.+) RewriteCond %{HTTPS}s/%1 ^(on(s)|offs)/(.+) RewriteRule ^ http%2://%3%{REQUEST_URI} [L,R=301] RewriteCond %{HTTP:X-Forwarded-Proto} =http RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
This code is universal and you do not need to change anything in it.
UPDATE: Sometimes the code above does not work, then you can use this one:
RewriteCond %{HTTPS} !=on RewriteCond "%{HTTP_HOST}" "^www\." [OR] RewriteCond "%{HTTP_HOST}" "^YOURWEBSITE.eu" [NC] RewriteCond "%{SERVER_PORT}" "^80$" RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{HTTP_HOST} ^(.+)\.YOURWEBSITE\.eu$ [NC] RewriteRule ^ https://YOURWEBSITE.eu [L,R] RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
There you have to change YOURWEBSITE to your domain. This code never failed me.
Done!
Easy as that. You do not need to change anything in Drupal database. Drupal is clever enough to make things work out of the box.