Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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:

/wp-admin/(.*)$
/wp-login.php$
/wp-register.php$

I hope that makes sense...

share|improve this question

1 Answer 1

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

 
discard

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.