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! Quote Link to comment 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(); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.