skip to Main Content

I have a website say abc.com ,when I enter a wrong address like abc.com/somthing.php it shows a 404 not found but when I enter the address like abc.com/index.php/something.php it does not show the 404 error. Any suggestions?

2

Answers


  1. The request

    abc.com/somthing.php
    

    gives you 404 because something.php file does not exist on the server.

    On the other hand, the request

    abc.com/index.php/something.php
    

    gives you 404 only if index.php does not exist on the server. If abc.com/index.php resides on the server, then it is accessed and the string /something.php is actually treated as a variable, that can be read with the $_SERVER['PATH_INFO'].

    If your index.php file looks like this

    <?php
    echo $_SERVER['PATH_INFO']
    ?>
    

    and you access it using abc.com/index.php/something.php then the output will look like something.php.

    For further info, feel free to check the documentation

    Login or Signup to reply.
  2. https://www.digitalocean.com/community/tutorials/how-to-create-a-custom-404-page-in-apache

    This should help

    Keep in mind that the Apache looks for the 404 page located within the site’s server root. Meaning that if you place the new error page in a deeper subdirectory, you need to include that in the line, making into something like this:

    ErrorDocument 404 /error_pages/new404.html
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search