I have my page at a shared host. In general the site is reachable using http and https. The page serves ads and most of the ads are not available using https therefore I only want the admin parts to be reachable via https.
What I want is:
http://myurl.com/auth -> https://myurl.com/auth
http://myurl.com/admin -> https://myurl.com/admin
https://myurl.com/allotherstuff -> http://myurl.com/allotherstuf
Basically all requests to auth and admit should be redirected to use ssl.
Requests to other sites should be redirected from https to http (if the page is requested using https).
I tried the following .htaccess file, which makes "auth" and "admin" unreachable (too many redirects).
RewriteEngine On
#Redirect other sites to http
RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} !^/?auth.*$
RewriteCond %{REQUEST_URI} !^/?admin.*$
RewriteRule ^/?(.*) http://%{SERVER_NAME}/$1 [R,L]
#Redirect auth and admin to https
RewriteCond %{HTTPS} !=on
RewriteRule ^/?auth/(.*) https://%{SERVER_NAME}/auth/$1 [R,L]
RewriteCond %{HTTPS} !=on
RewriteRule ^/?admin/(.*) https://%{SERVER_NAME}/admin/$1 [R,L]
Is it possible to accomplish this using mod_rewrite?
Comments
Post a Comment