Answer the question
In order to leave comments, you need to log in
How to show a 404 page without a redirect immediately if it is not there?
There is a page like /catalog/category/product/bla-bla redirected to a page with a slash. From this page, a page of the form /catalog/category/product/bla-bla/ is redirected and only then a 404 status is given. How to make it so that if the page does not exist, then without a redirect, give a 404 status?
Redirects are described as follows
RewriteCond %{REQUEST_URI} /[^/.]+$
RewriteRule ^(.*)$ https://localhost/$1/ [R=301,L]
RewriteCond %{QUERY_STRING} ^oid=(.*)
RewriteRule ^(.*)$ /$1? [R=301,L]
RewriteCond %{THE_REQUEST} /index\.php [OR]
RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^(.*?)(index\.php|$) https://localhost/$1 [R=301,L]
Answer the question
In order to leave comments, you need to log in
there is no point in doing this, htaccess is a very specific thing and the subrequest will slow it down a lot.
secondly, again, I don’t know what time.
Both Yandex and Google look only at the last code, they skip the entire chain.
so if it's 301 301 301 404 then it's 404
but how to exclude a file from the index is a separate story, there are more than enough tools here.
I'm already honestly tired
of fighting with this hat
RewriteCond %{THE_REQUEST} /index\.php [OR]
RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^(.*?)(index\.php|$) https://localhost/$1 [R=301,L]
htaccess is processed before dynamic code is executed. Those. the system does not know in reality whether such a page exists or not.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question