PHP + custom 401 redirect error.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
thiscatis
Forum Contributor
Posts: 434
Joined: Thu Jul 20, 2006 11:00 am

PHP + custom 401 redirect error.

Post 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?
jabbaonthedais
Forum Contributor
Posts: 127
Joined: Wed Aug 18, 2004 12:08 pm

Post 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.
thiscatis
Forum Contributor
Posts: 434
Joined: Thu Jul 20, 2006 11:00 am

Post 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/?
jabbaonthedais
Forum Contributor
Posts: 127
Joined: Wed Aug 18, 2004 12:08 pm

Post by jabbaonthedais »

Perhaps it is the header in error.php as you said. Take it out and test the file without it.
Post Reply