Reputation:
How do I use PHP to check whether a folder is password protected or not? I am using a PHP script that check for return codes 401 and 403 but when it runs into a folder that is password protected it recognizes that its a 403 but does not allow the popup box for username and password to display? How do I detect that the folder is password protected so I can tell my script to ignore it?
Upvotes: 0
Views: 254
Reputation: 75496
Assuming the server uses standard HTTP Authentication, the page is password protected if following conditions are met,
Zhihong
Upvotes: 0
Reputation: 19030
Actually 403
means forbidden. A password-protected resource would normally return 401 Unauthorized
.
You already have the information you need: The HTTP response code (403
or whatever) is how you know that the resource (folder, file) is inaccessible.
Upvotes: 3
Reputation: 154603
You say you already have a script to check if the header code is 401 and 403 and yet you want to know how you can check if a page sends a 403 header?
Perhaps you mean talking about the Authentication header.
Upvotes: 0