troubleshooting Question

mod_rewrite check HTTP_COOKIE exists redirect infinite loop problem

Avatar of NevilleChinan
NevilleChinan asked on
Web DevelopmentApache Web ServerWeb Servers
2 Comments2 Solutions4550 ViewsLast Modified:
Hi I am trying to implement a website security system.  It works on the bases of cookies beeing set by login.php
i.e login.php will setcoookie(...) and send the user to the homepage.  Every page that is on the site will do a quick auth check and reset the cookie in specific the time + 3hrs.  
 
The main protection is in the config file for apache

in the <directory> directive for the directory that corresponds to the virtual host test.webpage.co.uk
I have the following code

<Directory "C:/Program Files/Apache Group/Apache2/htdocs/test">
   Options FollowSymlinks
   RewriteEngine On
   RewriteCond %{HTTP_COOKIE} !(sessionid) [NC]
   RewriteRule ^.*$ http://test.webpage.co.uk/login.php [L,R]
   RewriteCond %{REQUEST_URI} ^/index.php
   RewriteRule (.*) http://test.webpage.co.uk/ [L,R]
</Directory>

I tired setting a cookie first before entering the lines
   RewriteCond %{HTTP_COOKIE} !(sessionid) [NC]
   RewriteRule ^.*$ http://test.webpage.co.uk/login.php [L,R]
into the config file.  Everything works

now I entered the lines
  RewriteCond %{HTTP_COOKIE} !(sessionid) [NC]
   RewriteRule ^.*$ http://test.webpage.uk/login.php [L,R]
into the config file.  Everything works

Now when I delete the cookies fire fox displays

The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete

So if anyone needs to login for the first time that will be the page they see.  The page is redirecting to the right page, the url says http://test.webpage.co.uk/login.php on anything i try to access even files like http://test.webpage.co.uk/movies/k.wmv will redirect to login.php however never loads the page correctly
really stuck, any way around this?
ASKER CERTIFIED SOLUTION
Robin HickmottSoftware Developer
Join our community to see this answer!
Unlock 2 Answers and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros