Why do non-existent pages give 200 responses?

  • 0
    The site has pages like site.ru/some_page.php
    but no page like
    site.ru/some_page.php/many_different_symbols
    and in theory a 404 page should open at this URL, but instead the server gives a 200 response and opens
    site.ru/some_page.php/many_different_symbols
    (only the site is static and all paths are relative - scripts, styles and pictures are not displayed).
    How to get a 404 response from such pages or redirect them to a 404 page.
    htaccess Fiona Lawrence, Mar 23, 2019

  • 2 Answers
  • 0
    Adding the AcceptPathInfo Off directive to the .htaccess file didn't help in my case.

    But the following rules helped, maybe someone will come in handy:

    To cut off everything after site.ru/some_page.php and get the existing page:

    RewriteRule ^ (. * Php) /.+$ / $ 1 [R = 301, L]



    Or to get a 404 page:

    RewriteRule ^ (. * \. Php) \ / (. *) $ /404.php [R = 301, L]
    Anonymous

  • 0
    AcceptPathInfo

    In .htaccess add

    AcceptPathInfo Off
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!