When we find any broken link or dead link, WordPress redirects all these pages to 404.php. So, Now no need to worry about these 404 error as here is the code to redirect all 404 pages directly to the home page. Just go down and check out the code to get into it. As a, Web Developer it will very helpful.
Follow the below steps to complete it successfully :-
Visit your theme's folder > Open 404.php file, if it is not there then make a new file with the same name> Delete all the code and text inside this file.>At last paste the below code in that file and save it.
<?php
//Redirect 404 page to the home page
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".home_url());
exit();
?>
Follow the below steps to complete it successfully :-
Visit your theme's folder > Open 404.php file, if it is not there then make a new file with the same name> Delete all the code and text inside this file.>At last paste the below code in that file and save it.
<?php
//Redirect 404 page to the home page
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".home_url());
exit();
?>
0 comments:
Post a Comment