Is it possible to rewrite some query strings to HTTPS and keep everything else on HTTP?

Posted by Matt on Server Fault See other posts from Server Fault or by Matt
Published on 2012-07-01T14:31:48Z Indexed on 2012/07/01 15:17 UTC
Read the original article Hit count: 282

I'm rewriting query strings to pretty URIs, example: index.php?q=/en/contact becomes /en/contact and all works nicely..

# httpd.conf

# HANDLE THE QUERY
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Is it even possible to rewrite single queries to force https and force everything else onto http? I've tried many different approaches that typically end in infinate loops. I could write a plugin to do this in PHP but figured it would be more effecient to handle this in the server conf. I'd be greatful for any advice.

EDIT: To clarify, I'd like to be able to rewrite the non SSL http://example.com/index.php?q=/en/contact to the SSL enabled https://example.com/en/contact and every query that is not /en/contact get written to http://example.com/...

© Server Fault or respective owner

Related posts about apache2

Related posts about mod-rewrite