Page 1 of 1

PHP + custom 401 redirect error.

Posted: Sat Mar 17, 2007 8:20 am
by thiscatis
I'm using

ErrorDocument 401 /error.php

In my htaccess file in a protected folder on my ftp,
error.php redirects to index.php/mode/error/
But if I upload that htaccess file it doesn't ask to login anymore,
it immediately redirects to the error page..
when I just put a normal html file

ErrorDocument 401 /error.html

it works again...

any input?

Posted: Sat Mar 17, 2007 10:59 am
by jabbaonthedais
That seems really strange. I just tested on my server and changing from .html to .php makes no difference. Are you getting an error? I know there was a bug in PHP 4.0.0 that caused an error with 401 pages instead of redirecting. That was fixed in 4.0.2.

Posted: Sat Mar 17, 2007 11:13 am
by thiscatis
nope, no error at all,
real strange.

Case:
ErrorDocument 401 /error.html
with error.html just a normal static html page
>> Works, asks to login, if fail redirect to error.html

Case
ErrorDocument 401 /error.php
with error.php a header redirect to index.php/mode/error/
>> Just redirects immediately to the error page instead asking to login.

Maybe it's because i'm redirecting twice? one time from 401 to error.php and a header redirect in error.php to index.php/mode/error/?

Posted: Sat Mar 17, 2007 11:23 am
by jabbaonthedais
Perhaps it is the header in error.php as you said. Take it out and test the file without it.