View Full Version : htaccess rewrite messes with the error document?

04-07-2011, 02:51 PM

I'm going to open a new thread, after my 'unanswered' one in the same forum, since I'd like to give a new title and some demo links.

I need to redirect all incoming requests to index.php, using .htaccess, and based on the $_SERVER['REQUEST_URI'], index.php will serve the pages. If the incoming request is not a valid one, a 404 header also need to be passed.

So, the short version of my files are as follows

header( 'Status: 404' );
<!DOCTYPE html>
<body >
<h1 >
<div>Lorem ipsum [...]</div>

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]
#I'm not the first one to try the above rule, it's taken from Wordpress's permalink-htaccess

The url is http://my-spread.com/error_test/. There's nothing more inside this directory, other than the above two files.

Now, all the (virtual) urls that may point to static files like foo (http://my-spread.com/error_test/foo), foo.txt (http://my-spread.com/error_test/foo.txt), foo.bar (http://my-spread.com/error_test/foo.bar), foo.html (http://my-spread.com/error_test/foo.html) etc are okay in all browsers (including lynx!)

But, all (virtual) urls that may point to dynamic files like foo.php (http://my-spread.com/error_test/foo.php), foo.py (http://my-spread.com/error_test/foo.py), foo.pl (http://my-spread.com/error_test/foo.pl), foo.rb (http://my-spread.com/error_test/foo.rb) are showing the error (Chrome somehow fixes the output, illegally? ;)).

Additionally, the output of index.php (http://my-spread.com/error_test/index.php) is even strange!

(And here's the phpinfo (http://my-spread.com/error_test/phpinfo.php), for those interested)

My mind doesn't allow me to believe that apache can show miracles, as "they" do. What do you think?

PS: I'm almost sure that it's all due to the lack of knowledge of the so called "techies" of the hosting team, and by the virtue of it I'm very reluctant to leave them :p :D

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum