Manual Http error response code in non-existent folder via routing

Posted by Slytherin on Server Fault See other posts from Server Fault or by Slytherin
Published on 2014-06-05T14:28:42Z Indexed on 2014/06/05 15:26 UTC
Read the original article Hit count: 165

Filed under:
|
|

Apache server running on ubuntu-like linux

I am getting unexpected behaviour when i try to manually send error response. If my .htaccess is responsible for the error response , then appropriate error document is loaded and displayed , with according response code in browser console.

However , if my router is origin of the response code , then i get blank screen , but correct response code.

.htaccess looks like this

RewriteEngine On
# RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(css|js|icon|zip|rar|png|jpg|gif|pdf)$ index.php [L]

ErrorDocument 404 /err/404.html
ErrorDocument 403 /err/403.html
ErrorDocument 500 /err/500.html

part of my router that sends the response is the following

header("HTTP/1.1 403 Forbidden");

trying this format didnt help either

header("HTTP/1.1 403 Forbidden", TRUE, 403);

I also tried HTTP/1.0. Furthermore i was thinking that maybe relative path to error page might be an issue , but discarded this idea after attempting to access a document that is forbidden via .htaccess

EDIT

I should also point out , this scenario happens when URL for not-existing article is requested. Is it possible that Server is looking for a .htaccess file in a folder based on URL ? Eg: domain/blog/non-existent , is server looking for blog folder ? I am specifically asking this because there is no blog folder

© Server Fault or respective owner

Related posts about apache-2.2

Related posts about .htaccess