Support » Plugins » Hacks » redirect all 404's from one directory to index page of that directory

  • onemorewpsuser

    (@onemorewordpressuser)


    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!

Viewing 1 replies (of 1 total)
  • Thread Starter onemorewpsuser

    (@onemorewordpressuser)

    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();
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘redirect all 404's from one directory to index page of that directory’ is closed to new replies.