.htaccess redirect loop

djcustom

New Member
Messages
17
Reaction score
0
Points
0
I have been working on the following code for quite some time and I cant seem to find what is causing the loop.

domain.com/category - works correctly
domcin.com/category/?id=12 - redirect loop.

Code:
RewriteEngine On
RewriteBase /
#Redirect For get variables.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ cat.php?cat=$1 [QSA,L]


#Create redirect for all nonexistant folders to the category file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/(.+)$
RewriteRule ^(.*)/? cat.php?cat=$1 [QSA,L]


#Redirect login.php and subdirectories to https and all others to http
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} login.php
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}


#Forwards unnecessary https back to http
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !login.php
RewriteCond %{REQUEST_URI} !css
RewriteCond %{REQUEST_URI} !img
RewriteCond %{REQUEST_URI} !images
RewriteCond %{REQUEST_URI} !tabs
RewriteCond %{REQUEST_URI} !scripts
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

If i Remove the "forwards unnecessary https back to http" section the loop is removed but I cant quite figure out what is causing the loop in that section
 
Top