Force SSL on one page via .htaccess without looping
Posted
by
Will Martin
on Server Fault
See other posts from Server Fault
or by Will Martin
Published on 2011-06-23T17:44:11Z
Indexed on
2011/06/24
0:24 UTC
Read the original article
Hit count: 507
Okay, I have this code:
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/borrowing/ill/request\.php$
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
The way I would expect this to work is:
- A request for /borrowing/ill/request.php comes in on HTTP.
- The rule matches.
- The server redirects to HTTPS.
- The rule does not match, because HTTPS is now on.
The way it actually works is:
- A request for /borrowing/ill/request.php comes in on HTTP.
- The rule matches.
- The server redirects to HTTPS.
- The rule matches.
- The server redirects to HTTPS.
- The rule matches.
- The server redirects to HTTPS ...
And so on.
I know that the second condition (matching the file name) is working, because the redirect loop only hits that specific page. The question is, why isn't the switch to HTTPS causing the first condition to not match?
EDIT:
I put the exact same .htaccess rules into a test area on another server -- same file and path info. And they worked just fine. There's got to be something wrong with the server configuration elsewhere.
© Server Fault or respective owner