.htaccess https redirect problem

.htaccess

I've got a directive set up in my htaccess to send all non-https traffic to https

RewriteCond %{SERVER_PORT} ^80$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

# These are used by the Zend Framework...
RewriteCond %{REQUEST_FILENAME} \.(js|css|gif|jpg|png|swf)$ [OR] 
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

I now need to add two exceptions to stop them being redirected to https – one for mydomain.com/register/ and one for mydomain.com/services/test/

Could anyone help me out?

Thanks.

Best Answer

Ok, someone helped me to get it working using:

 RewriteEngine On

 RewriteCond %{SERVER_PORT} !^443$
 RewriteCond %{THE_REQUEST} !/services/test
 RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

 RewriteCond %{REQUEST_FILENAME} \.(js|css|gif|jpg|png|swf)$ [OR]
 RewriteCond %{REQUEST_FILENAME} -s [OR]
 RewriteCond %{REQUEST_FILENAME} -l [OR]
 RewriteCond %{REQUEST_FILENAME} -d
 RewriteRule ^.*$ - [NC,L]

 RewriteCond %{THE_REQUEST} /services/test
 RewriteRule ^.*$ index.php [NC,L]

 RewriteRule ^.*$ index.php [NC,L]

The Zend Framework rewrite rule was causing a problem, but it's working ok now.

Related Topic