young_coder Posted March 25, 2012 Share Posted March 25, 2012 Hello guys, There are some Wordpress plugins for permanent redirection of all 404's to the main blog URL (plugin '404 Redirection') or all 404's to one specified page (plugin '404-to-start'). Also, it can be done by adding following code to the theme's 404.php page. <?php header("HTTP/1.1 301 Moved Permanently"); header("Location: ".get_bloginfo('url')); exit(); ?> I need to redirect all 404's from one directory to index page of that directory. Does anybody know how this can be done? Thank you! Link to comment https://forums.phpfreaks.com/topic/259701-wordpress-redirect-all-404s-from-one-directory-to-index-page-of-that-directory/ Share on other sites More sharing options...
young_coder Posted March 25, 2012 Author Share Posted March 25, 2012 maybe someone will find it useful it can be done by adding following code to the theme's 404.php page <?php header("HTTP/1.1 301 Moved Permanently"); header("Location: ".dirname($_SERVER['REQUEST_URI']).'/'); exit(); ?> Link to comment https://forums.phpfreaks.com/topic/259701-wordpress-redirect-all-404s-from-one-directory-to-index-page-of-that-directory/#findComment-1331032 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.