Why do non-existent pages give 200 responses?
The site has pages like site.ru/some_page.php
but no page like
and in theory a 404 page should open at this URL, but instead the server gives a 200 response and opens
(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
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
In .htaccess add
To place the code, please use CodePen or similar tool. Thanks you!