0

I have a secure site, and am currently redirecting visitors to it if they access through the unsecured http://. I am doing that like so:

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

I need one file, domain.com/example.php to not ever be redirected to the secure site, and just keep the user there. Can anyone suggest a way of doing this? I've looked at similar code, but I can't work out what needs to be changed to work exactly

Thanks!

Jonathon Blok
  • 749
  • 4
  • 14

2 Answers2

3

Just use an additional RewriteCond to filter out your URI:

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !/example.php
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

see mod_rewrite documentation

mensi
  • 9,580
  • 2
  • 34
  • 43
0

This previous SO answer will help: .htaccess mod_rewrite - how to exclude directory from rewrite rule

Basically, you'll need a rewrite rule above the existing rules that "rewrites" your desired URLs to themselves.

Community
  • 1
  • 1
Benjamin Cox
  • 6,090
  • 21
  • 19