How can numeric URLs refer to 404? (Multilanguage site on wordpress under the plugin Polylang) examples: http://foo.com/123432 && http://foo.com/bar/123432 After entering characters, it only adds a slash / 12312 / and remains on current page, but not 404? Tried and RewriteRule did not help
- If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky ♦
|
1 answer
Try this
RewriteEngine On RewriteCond %{REQUEST_URI} ^(.*/)?\d+/?$ RewriteRule ^ - [R=404,L] I don’t remember from which version of Apache the redirect works beyond 300x codes, on version 2.4 it works.
Regular to filter url
^(.*/)?\d+/?$ ^ - the beginning of the line(.*/)? - optional group, captures all the characters from the beginning of the line to the slash in front of the numbers along with the slash,\d+ - from 1 to infinity numbers,/? - optional slash at the end of the line,$ - end of line.
Will respond to http://foo.com/123432 and to http://foo.com/123432/ , to http://foo.com/bar/123432 and to http://foo.com/bar/123432/ .
- thanks) everything as the doctor prescribed) - Lieutenant Jim Dangle
|