Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts

    Setting index.php to handle "all" incoming requests

    Hello,

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

    I've and .htaccess file with
    Code:
    RewriteEngine On
    Options -Indexes
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?page=$1 [L]
    and an index.php with
    PHP Code:
    <?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?

    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
    Last edited by abduraooft; 03-16-2011 at 10:31 AM.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Here's a few more test results from my end.

    None of the urls like
    Code:
    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
    Code:
    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.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •