Created
February 15, 2019 12:39
-
-
Save imelgrat/29148412bf200952d173e8e3deaf487d to your computer and use it in GitHub Desktop.
Redirect WordPress dead-links to the homepage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Redirect missing WordPress URLs . | |
* | |
* If you want to redirect the browser every time a page can’t be found while avoiding SEO impact, you can open your 404.php file | |
* in your theme’s folder and paste this at the top. If it doesn’t exist, then create a blank 404.php file. | |
* | |
* @link https://imelgrat.me/wordpress/dead-links-redirect-avoid-seo-impact/ | |
*/ | |
header("HTTP/1.1 301 Moved Permanently"); | |
header("Location: " . get_bloginfo('url')); | |
exit(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment