开发者

{REQUEST_URI} in .htaccess not matching properly for SSL rewrite

Hey, 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]

So I'm going to this page: http://shop.mysite.co.uk/auth/login - hoping it's forced to be https by .htaccess

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 won't work! When I go to http://shop.mysite.co.uk/auth/login it just loads the page using http as normal and not https.

It seems to be this: RewriteCond %{REQUEST_URI} auth/login that is not working properly, if I remove that line it redirects any url to https://shop.mysite.co.uk/auth/login.


If you’re using other rules besides the mentioned one, make sure to put those rules, that cause an external redirect (i.e. R flag), in front of those rules, that only cause an internal rewrite. Otherwise an already internally rewritten rule can already have changed your request URL and your pattern will not match.


REQUEST_URI will have a prefixing slash. This should work:

RewriteCond %{REQUEST_URI} /auth/login
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜