How to redirect to 404 page not found in opencart using .htaccess?

by cameron_walter , in category: SEO , 3 months ago

How to redirect to 404 page not found in opencart using .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer

Member

by zion , 3 months ago

@cameron_walter 

To redirect to a 404 page not found in OpenCart using .htaccess, you can add the following code to your .htaccess file:

1
2
3
4
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?route=error/not_found [L]


This code will check if the requested file or directory does not exist (!-f and !-d), and if so, it will redirect to the OpenCart's Error Controller with the "not_found" action.


Note: Make sure to backup your .htaccess file before making any changes and clear your browser cache after saving the changes.