Answer the question
In order to leave comments, you need to log in
Why do non-existent pages return a 200 response?
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 on such pages or redirect them to a 404 page.
Answer the question
In order to leave comments, you need to log in
Adding the AcceptPathInfo Off directive to the .htaccess file did not help in my case.
But the following rules helped, maybe it will come in handy for someone:
To cut off everything that comes after site.ru/some_page.php and get an existing page:
RewriteRule ^(.*php)/.+$ /$1 [R=301,L]
Or to get 404 page:
RewriteRule ^(.*\.php)\/(.*)$ /404.php [R=301,L]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question