Answer the question
In order to leave comments, you need to log in
CNC and 404 page failing on bad request?
A very simple question.
RewriteRule ^gorod/(.+)/category/(.*)$ view-product.php?city=$1&id=$2 [L] Gorod gives page 404 when changing, but when category
changes (add any categzukory characters there ) 404 page is not returned, why?
Answer the question
In order to leave comments, you need to log in
You have a get request in the url,
and it, in turn, is not part of the url
, moreover, you do not exclude the slash from the first regular expression, and therefore it satisfies any value, including a category with any spelling.
In your case, you need to do something like this
1. separate get requests separately, it will be more correct
2. exclude the slash in the range
RewriteCond %{QUERY_STRING} (^|&)city\=\$1($|&)
RewriteCond %{QUERY_STRING} (^|&)id\=\$2($|&)
RewriteRule ^gorod/([^/].+)/category/([^/].+)/view\-product\.php$ /? [R=404]
Solved the problem like this:
RewriteRule ^gorod/(.+)/(.*)/(.*)$ view-product.php?city=$1&category=$2&id=$3 [L]
+ php handler and
header(" HTTP/1.0 404 Not Found");
include 'errors.php';
exit();
But it's still interesting, could it be decided in htaccess or not? what did you do wrong? just not good at it...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question