.htaccess https redirect help

Status
Not open for further replies.

davkell

New Member
Hey,

I've got a directive in my .htaccess file to redirect all non-https traffic to https -

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

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

Any suggestions on how to do this?

Cheers.
 

php.allstar

New Member
Hi,

I'm not sure as I can't test this, but give it a go and let me know how you get on:

Code:
RewriteCond %{HTTP_HOST} !^domain.com(/register|/services/test/)$ 
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
 

davkell

New Member
Thanks for taking a look.

No, I'm getting an error saying there's a redirect loop. I should probably have included the rest of the htaccess with the code:

Code:
RewriteCond %{SERVER_PORT} ^80$
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]
RewriteRule ^.*$ index.php [NC,L]
 
Status
Not open for further replies.
Top