Answer the question
In order to leave comments, you need to log in
How to make Apache or Yii return 404 without 301?
Good afternoon! There was such a question. We have a site on Yii1. And we want to add a slash to the end of the URL. We do it like this:
# Enforce trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*[^/])$ /$1/ [L,R=301]
Answer the question
In order to leave comments, you need to log in
Well, without PHP, how do you know if there is such a page or not?
The question is old and rhetorical, it has nothing to do with the engine.
THIS has to do with the parser of the server response code, whether it takes a sequence of codes or the last one.
In fact, the final 404 will indeed return a non-existent page and the search engine will understand that it does not exist and mark it as non-existent, but the redirect url itself may not change because it returns a valid server response.
You can check the response code in .htaccess, but thus, with each hit, you need to wait for the server's response, and only after that something will happen at all. A line-by-line dynamic re-reading of this file can potentially add hemorrhoids.
So I would not recommend checking the response code through .htaccess.
AND SO WHAT CAN BE DONE.
The first is to set up a tray file, etc. in nginx, there is a richer toolkit for this, and it reads server response codes on the fly, it’s better than in .htaccess
.
if they appear there dynamically, solve the problem with your engine.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question