Table of Contents
404 errors on static content will lead to the Magento bootstrap (
index.php) being loaded in place of content. Even with the fastest of stores, a call to
index.php can come at a minimum cost of
If you multiply that by the number of 404 elements on your page, it can really add up.
Configuring a 404 error page for static content
We still want dynamic 404's to hit Magento, but for any static content (eg. CSS/JS/images) - its much better to serve a plain placeholder HTML page than hit the Magento bootstrap needlessly.
- All you need to do is create a directory (which usually already exists on a Magento store) called
- Within this directory, create a file called
404.htmland customise it however you wish.
Then to test if your changes have worked, just visit your website and try and view a non-existent URL
The default Magento
404.php looks like this, which you can style with the respective
default template directory in the
./errors directory. This is a good mechanism and does not introduce too much overhead - and allows for easier deployment of custom 404 pages for different stores, but if you want an extremely lightweight version, use the pure PHP/HTML alternative below.
$processor = new Error_Processor();
Alternatively, if you want something simpler, you can use ordinary PHP/HTML to achieve the same result.
header("HTTP/1.0 404 Not Found");
Configuring a 404 error page for dynamic content
At present, we still let all dynamic content hit Magento's bootstrap - as the server cannot distinguish what is or isn't a real URL.
But this doesn't mean that you should ignore 404 dynamic content. 404 pages for Magento are very costly; as the response is not cached by Magento - so each time someone hits a 404 page, it is consuming server resources.
It is a good idea to regularly review logs and add Nginx rewrite rules to redirect 404 content with a 302 or 301 status back to your homepage (or a suitable replacement page).
Finding 404 errors
Access either the load balancer or web server Kibana dashboard
Then use the search string