I have a query with regards to .htaccess and redirecting some things.
I currently have a site that requires sitewide HTTPS. This is done via the .htaccess file.
I require two things to be on HTTP however: /sage/ and /index.php?route=ebay/openbay.
I currently have the following in place for sage, and it works. There is no loop and the redirect works fine.
RewriteCond %{HTTP_HOST} ^(www\.)?site\.co\.uk$ [NC]
##check if https
RewriteCond %{HTTPS} on
## if so, redirect to http
RewriteRule ^/?(sage) http://www.site.co.uk%{REQUEST_URI} [L,R]
## happy days! it works!
RewriteCond %{HTTP_HOST} ^(www\.)?site\.co.uk$ [NC]
##lets check again but this time for any remaining http
RewriteCond %{HTTPS} off
##if so redirect it back to https, unless sage is at the start.
RewriteRule !^/?(sage) https://www.site.co.uk%{REQUEST_URI} [L,R]
##great, still ahve sitewide https except on sage, mission accomplished.
Now, I have the problem of the line with the query string.
This is what I have, and it is placed under the above code in the htaccess.
RewriteCond %{QUERY_STRING} route=ebay/openbay/ [NC]
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}/$1 [L,R]
RewriteCond %{QUERY_STRING} !route=ebay/openbay/
RewriteCond %{HTTPS} off
RewriteRule (.*) http://%{HTTP_HOST}/$1 [L,R,NC,QSA]
Not only does this work, it creates a redirect loop with this and sage. I'm not sure why and I'm a little stuck.
I originally took the idea from an old post: Redirect some url to https in .htaccess, hoping that I could just add the two strings in the brackets so (sage/index.php etc)
I'm at a bit of a loss now, so I think its time to ask the world for help.