I would like to force the browser to redirect to HTTPS always if someone types in:
http://www.mydomain.com/user
or
http://www.mydomain.com/user/
Both of the above 2 links should redirect to: https://www.mydomain.com/user
Right now the 2nd to bottom line of code works correctly:
RewriteRule ^user$ https://www.mydomain.com/user/ [R,QSA]
will indeed redirect the browser to HTTPS but if http://www.mydomain.com/user/ is input then it won’t redirect to HTTPS. How can I achieve this?
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]
RewriteRule ^user$ https://www.mydomain.com/user/ [R,QSA]
RewriteRule ^user/$ public/index.php?var1=x&var2=y [L,QSA]
Use these rules:
It will redirect to HTTPS:
/userand/user/will do the job (but will do nothing if/user/something-herewill be requested).