Force HTTP Status Code form Apache Web Server

I had strange problem where in i have to force an HTTP Status Code from Apache Web Server. I tried using PHP to return the header having HTTP status code but even that was showing HTTP 200 OK status inside HTTP Headers. I started debugging this and found that the way Apache Web Server works it will accept the HTTP status code received from PHP and will redirect the request to ErrorDocument inside Apache Web Server. After much googling i found that we can force an HTTP Status code for particular directory/file using .htaccess files.
Continue reading