Redirect 404 errors to /

Cold-Egg

Administrator
#4
You can also try following rules if ErrorDocument not supported

Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . / [L]
 

Pong

Administrator
#8
rewrite rule might be conflicting with each other so order of the rules is important.

for example:
https://github.com/magento/magento2/blob/2.3/.htaccess
in Magento 2.3 default .htaccess, if the files/folders don't exist, it will redirect to index.php already.
Code:
## never rewrite for existing files, directories and links

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

############################################
## rewrite everything else to index.php

    RewriteRule .* index.php [L]
 
Last edited:
Top