Forums / Install & configuration / Rewrite Rule to Leave SSL

Rewrite Rule to Leave SSL

Author Message

Rob Pratt

Thursday 23 March 2006 10:50:49 pm

I'm stuck on Apache rewrite rules for moving a user to SSL when in the webshop and then moving out of SSL when the user leaves the webshop. I have no problem going to secure, as the following rules work in the httpd.conf for the nonsecure virtual host:

RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*/plain/shop/(.*) https://%{SERVER_NAME}/plain/shop/$1 [R,L]

After searching and searching and searching this forum and working for hours to write rewrite rules for the httpd.conf for the secure virtual host, I'm stuck.

Can someone refer me to rules that might work to figure out if a URL is not in the webshop and rewrite to the nonsecure server?

All of the rewrite conditions I've tried cause infinite redirects. From reading the mod_rewrite docs, I'm led to believe that it should be as simple as:

RewriteCond %{PATH_INFO} !^.*/plain/shop/(.*)
RewriteRule ^.*/$ http://%{SERVER_NAME}/$1 [R,L]

But it's not.

Jonny Bergkvist

Friday 24 March 2006 1:10:35 am

Hi,

I have a working apache-ssl config that redirects back to http.

I use https for user-login (/user/*), and http for anything else.

The rewriterules in my normal apache-config are:
RewriteRule ^(.*)/user/(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L]
RewriteRule !\.(gif|css|jpg|png|jar|ico|js|pl)$ /ezroot/index.php

The rewriterules in my ssl-config are:
RewriteRule ^(.*)/user/(.*)$ /ezroot/index.php [L]
RewriteRule \.(gif|css|jpg|png|jar|ico|js)$ %{REQUEST_URI} [S=1]
RewriteRule ^(.*) http://%{HTTP_HOST}$1 [L]

Hope this helps :-)

Jonny

Rob Pratt

Monday 27 March 2006 11:01:02 am

Thanks for the example. I'll give it a try.