Home / Archive / Redirect 404 to Homepage
Duplicate Snippet

Embed Snippet on Your Site

Redirect 404 to Homepage

Automatically redirect 404 pages to the homepage.

200+
Code Preview
php
<?php
add_action( 'template_redirect', function() {
	if (is_404()) {
    	wp_safe_redirect(home_url());
	    exit();
	}
} );

Comments

Add a Comment