Hi!
I actually have two questions regarding setting headers with the php headers()-function.
The first is regarding what error response to send if a user tries to access a password protected page without logging in. It seems logical to send a 401 - Unauthorized, but the protocol states that
But since I don't want a user/pass-popup it doesn't seem like a good alternative. Is 403 - Forbidden better to use in that case? Or maybe some kind of 3xx-redirect to the main page?
The second question is about error pages. If I type a unknown URI a "HTTP/1.1 404 Not Found" response is given and x10hosting will use your custom error page (or it's own). But if you generate your own error with header("HTTP/1.1 404 Not Found") in an existing page the page still executes. Is it possible to send headers with php so that the server sends the client to your customized error pages? Or do you simply have to include them in the file that generates the error?
I actually have two questions regarding setting headers with the php headers()-function.
The first is regarding what error response to send if a user tries to access a password protected page without logging in. It seems logical to send a 401 - Unauthorized, but the protocol states that
(http://www.faqs.org/rfcs/rfc2616)10.4.2 401 Unauthorized
The request requires user authentication. The response MUST include a WWW-Authenticate header field (section 14.47) containing a challenge applicable to the requested resource.
But since I don't want a user/pass-popup it doesn't seem like a good alternative. Is 403 - Forbidden better to use in that case? Or maybe some kind of 3xx-redirect to the main page?
The second question is about error pages. If I type a unknown URI a "HTTP/1.1 404 Not Found" response is given and x10hosting will use your custom error page (or it's own). But if you generate your own error with header("HTTP/1.1 404 Not Found") in an existing page the page still executes. Is it possible to send headers with php so that the server sends the client to your customized error pages? Or do you simply have to include them in the file that generates the error?