Forum Moderators: coopster

Message Too Old, No Replies

How to check if a folder is password protected or not with PHP

Need to test for folder/file password protection

         

mikesz

1:49 am on Aug 12, 2009 (gmt 0)

10+ Year Member



I have an errorpage script that uses $_SERVER['REDIRECT_STATUS'] to check for the the return code on a request, i.e. 404, and delivers a user friendly message depending on which error condition it finds, works great most of the time. The problem is when is encountered a password protected folder, it delivers the 401 or 403 error message and completely ignores/bypasses the popup username/password window that usually occurs in .htaccess password protected folders.

What test / condition / variable do I need to use to check for if a folder is password protected in combination with the REDIRECT_STATUS to allow the popup window instead of automatically generating the 401 / 403 error messages?

TIA for any help. This was a total surprise to me after I deployed the script so I have a bit of a bind to fix it ASAP. I am sure its something simple but I have a clue at this point.

coopster

3:10 pm on Aug 15, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Without knowing/understanding your logic flow it may be difficult to offer advice for test/condition but you may start by reviewing the Apache docs that pertain to the underlying Custom Error Responses [httpd.apache.org] being employed in your application.