Hello,
As this is my first post i want to thank the community of ModX for this excellent CMS! however i have a problem.
I’m trying to return a header("HTTP/1.0 403 Forbidden"); status code for some documents. I have folder aliases turned on and some folders should look like it is a real directory which cannot be accessed directly. If googlebot sees an url like test.com/news/item1.html it probably tries to access the news folder too. I don’t want that in my scenario.
I tied making a snippet with this content:
<?php
header("HTTP/1.0 403 Forbidden");
?>
and a variations like these:
<?php
header("Status: 403 Forbidden");
?>
<?php
header("HTTP/1.0 403 Forbidden");
header("Status: 403 Forbidden");
?>
I called the snippets from within the documents content and nothing happened. A header("redirect:www.test.com"); did work. I dont understand what is the problem with the 403 header. Can give anyone advice?
-
MODX Staff
- 10,725 Posts
403; why not send 404?? Try using $modx->sendErrorPage() for a 404 and $modx->sendUnauthorizedPage() for a 401 or you can call $modx->sendForward() to send the request to another pages content silently and set the header to 403 if you want.
401 means "Show me your credentials"
403 means "Your credentials suck -- go away"
Just adding that as an FYI on why he might want one and not the other
oh btw, the proper way to send a header is:
header("HTTP/1.1 401 Authorization Required");
or
header("HTTP/1.1 403 Forbidden");