...

View Full Version : Setting index.php to handle "all" incoming requests



abduraooft
03-16-2011, 10:26 AM
Hello,

I'm having a frustrating issue with my shared server.

I've and .htaccess file with
RewriteEngine On
Options -Indexes

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1 [L] and an index.php with

<?php
# I need to call this header in my actual system, when the code in the index.php files finds a bad request. So this is the most simplified form of my code
header("HTTP/1.0 404 Not Found");
#header( 'Status: 404' );
?>

<!DOCTYPE html>
<title>Tets</title>
<body >
<h1 >
Header
</h1>
<hr/>
Footer
</body>

This works well on my local machine and on a different server. However it fails when test the same in this new server.

Say, when I request http://mysite.com/foo, I get

Header
Footer
(as expected), but when I access http://mysite.com/foo.php, I get
Header
Footer
Not Found

The requested URL /index.php was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Also, when I open http://mysite.com/index.php, I get
Header
Footer
Page not found
The page you are looking for might have been removed,
had its name changed, or is temporarily unavailable.
Please try the following:

If you typed the page address in the Address bar, make sure that it is spelled correctly.

- Click the Back button in your browser to try another link.
- Use a search engine like Google to look for information on the Internet.
HTTP 404 - File not found

I've been discussion with the support agents of the host, but they don't know the reason for this behavior.

Any clues? Anything wrong with my code? :confused:

PS: If I add an ErrorDocument 404 error.htm at the end of my htaccess, I get
Header
Footer
error.htm for both http://mysite.com/index.php and http://mysite.com/foo.php

abduraooft
03-25-2011, 03:51 PM
Here's a few more test results from my end.

None of the urls like

http://mysite.com/foo.txt
http://mysite.com/foo.bar
http://mysite.com/foo.html
http://mysite.com/foo.css
give any unexpected output.

BUT, all the urls like

http://mysite.com/foo.php
http://mysite.com/foo.py
http://mysite.com/foo.pl
http://mysite.com/foo.rb

clearly show the bug. Really weird.

Why the he** that server behaves like this?

Any clues would be appreciated.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum