Skip to content

Fast 404

Ben Gillbanks edited this page Nov 18, 2020 · 5 revisions

Disable 404's for static files.

This means that if an image (or other static file) is included in a page, and it doesn't exist, the entire 404 page will not be loaded.

An example of when this might be bad, would be if an image is deleted but still loaded somewhere. With normal WordPress this will make a request for a non-existant file, which will then generate a 404 response loading the 404 page. This will in turn perform database requests for widgets and other content that might be on the page.

The list of files currently blocked includes:

	$bad_file_types = array(
		'css',
		'txt',
		'jpg',
		'gif',
		'rar',
		'zip',
		'png',
		'bmp',
		'tar',
		'doc',
		'xml',
		'js',
		'docx',
		'xls',
		'xlsx',
		'svg',
		'webp',
	);

Redirect Filter

This module supports redirecting files to a different location through the use of the toolbelt_404_redirect filter. This filter works in exactly the same way as the one used in the Search Redirect module, and the documentation there explains how to use it.

Clone this wiki locally