Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ErrorDocument 401 + PHP redirect = no password dialog

Status
Not open for further replies.

cmcfarling

IS-IT--Management
May 24, 2004
53
US
I copied this question from experts-exchange.com because I couldn't have asked it any better. Plus there was no definitive answer over there and I cant find one anywhere.


There is a password protected directory /pw. The ErrorDocument 401 is set to a php file in the root directory. If the php file just outputs some text everything works file. But if i put a redirect in the 401 php file:

<? header("Location: /login_error.php"); exit; ?>

The password box never gets displayed and instead the user gets directed straight to the /login_error.php page. Whats the problem here?
 
My guess:

Apache reads the file before it pops the password dialog. Then, if the pw is bad, the file is ready to run.
Since you are including a header in your PHP example, Apache must have an order of precedence that says "first send ALL headers, then the password pop, then the 401 file if the password is bad".

My guess is that if you played with your header and sent something else instead of a location header, it would appear in the page headers for a "text output".

Just a guess.... again, try with a non-"Location" header just to see how it behaves.

D.E.R. Management - IT Project Management Consulting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top