Http to https rewrite woes

Hi all, i’m trying to use .htaccess to force SSL on a page on my website.

In my .htaccess i’m doing this:

RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} auth/login
RewriteRule ^(.*)$ https://shop.mysite.co.uk/auth/login [R=301,L]

and the url i’m trying to trigger with this is: http://shop.mysite.co.uk/auth/login

I know it works as i’m sure i had it working earlier. But i have a horrible feeling i changed something and don’t know what and now it wont work! When i go to http://shop.mysite.co.uk/auth/login it just loads the page using http as normal and not https.

If anyone can help me stop weeping on my desk at this problem i would be really grateful.

This rules are correct. Look at access_log when you get http://shop.mysite.co.uk/auth/login it works if you got a 301 response code

Yes that should work but you could simplify it:


RewriteCond %{SERVER_PORT} 80
RewriteRule ^auth/login$ https://shop.mysite.co.uk/auth/login [L,R=301]

(switching of L and R=301 doesn’t change anything. it’s just my personal preference to have L first ;))

Oh, and I assume you have RewriteEngine On in your .htaccess somewhere ?