I would like to redirect all users to https. This works fine with this code.
Code:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
# redirect if it looks like this https://domain.com/svrduzx8xCupDgJHpOdq
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.* - [L]
RewriteBase /
RewriteRule ^([a-zA-Z0-9]+)$ https://%{HTTP_HOST}/application.php?i=$1
But the problem is that some users still type www, resulting in
https://www.domain.com. This gives a ssl cert error.
So I would like to first strip the www before redirecting to https. I've tried different approaches, such as:
Code:
# remove www from host
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]
But I can't get it to work. .htaccess is pretty new to me, anyone with experience who knows how to get this done (properly)?