8

I've got a site that requires (obviously) HTTPS for checkout. The current fix put in place involved making the whole site run in SSL mode, but this is causing problems.

How would I change this...

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]

To only set a certain URL (say basket.php) as HTTPS?

sth
  • 222,467
  • 53
  • 283
  • 367
Meep3D
  • 3,803
  • 4
  • 36
  • 55

2 Answers2

13

A shorter version:

RewriteCond %{HTTPS} off
RewriteRule ^basket\.php$ https://%{HTTP_HOST}%{REQUEST_URI} [L]
Gumbo
  • 643,351
  • 109
  • 780
  • 844
  • How could I mod that to accept multiple pages? Say basket and checkout and blah? – bMon Feb 29 '12 at 17:51
  • Change the pattern `^basket\.php$` to whatever you want. If you need help with the regular expression, take a look at [Apache’s mod_rewrite Introduction](http://httpd.apache.org/docs/current/rewrite/intro.html). – Gumbo Feb 29 '12 at 17:54
  • "In this document, we attempt to provide enough of a regex vocabulary to get you started, without being overwhelming, in the hope that RewriteRules will be scientific formulae, rather than magical incantations." - heh, that was me to a tee - not anymore, thanks. – bMon Feb 29 '12 at 18:13
12

I beleive this would work:

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} /basket.php
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]
You
  • 22,800
  • 3
  • 51
  • 64