WordPress Redirect Visitor On 404 Error
WordPress shows a 404 page when visitor navigate to a non existent page. To redirect visitor to a specific page, say home page when visiting non existent page, edit functions.php file in your themes folder, then add following code to it.
function redirect_404_to_page() { if( is_404() ) { header( "Location: https://your-domain.tld/page/" , true, 404); exit; } } add_action( 'template_redirect', 'redirect_404_to_page' );
Back to WordPress