Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a site with only 3 URLs that need to be accessed via HTTPS. So I have 2 VirtualHost sections, one for HTTP (port 80) and the other for HTTPS (port 443).

Redirecting from HTTP to HTTPS is easy, I basically have this in the HTTP section:

RewriteEngine on
RewriteRule ^/wp-admin/(.*)$ https://%{SERVER_NAME}/wp-admin/$1 [R=permanent,L]
RewriteRule ^/wp-login.php$ https://%{SERVER_NAME}/wp-login.php [R=permanent,L]
RewriteRule ^/wp-register.php$ https://%{SERVER_NAME}/wp-register.php [R=permanent,L]

So whenever user wants to log in or register he will be redirected to a secure site. However, once the user has logged on, I don't want him to stay on HTTPS. Obviously, I could change WP code to redirect back to HTTP, but unfortunately that's not an option.

So the question is, how do I define RewriteRules in the HTTPS so that all requests will be redirected to HTTP only if they are not the following URLs:


I hope that makes sense...

share|improve this question

You can easily check the %{REQUEST_URI} with a RewriteCond. You can also check %{HTTPS} to find out whether the client uses http:// or https:// to access your site.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.