Configuring 404 errors in htaccess

There is an htaccess file with the following settings:

AddDefaultCharset UTF-8
Options +SymLinksIfOwnerMatch
Options -Indexes

RewriteEngine On
RewriteBase /
ErrorDocument 404 /404.php

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.+)$ /?menu=$1 [QSA,L]

If you enter an incorrect url, it redirects you to the main page of the site. Where I'm wrong. How to fix it?

Author: Вадим, 2018-04-02

1 answers

In this example, the directive ErrorDocument 404 /404.php does not make sense, because the construction

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.+)$ /?menu=$1 [QSA,L]

In fact, it is an implementation of the " handler "of the"Page not found" status.

And following all the rules in your example, mod_rewrite will eventually "stop" at the rule RewriteRule ^index.php$ / [QSA,R=301]

So decide what you need in the end.

 1
Author: de_frag, 2018-04-03 20:53:25