WordPress.org

Ready to get started?Download WordPress

Forums

404 redirection (6 posts)

  1. shadow
    Member
    Posted 9 years ago #

    Hi,
    I am trying to sort out my 404 stuff.

    I would like to make it so that visitors who end up at a 404 are redirected to a message contained within the site itself.

    For instance, going to http://shadows.os42.com/2005/03/25/its-not-going-to-be-easy-people/
    no longer works.

    So how do I redirect the visitor using my 404.php and 404.shtml to a page which has the header, sidebar and footer and a message telling them to go elsewhere?

    It is half happening here
    http://shadows.os42.com/404.php

    but obviously it is not right yet...

    Thanks for any advice you can offer :)

  2. Kafkaesqui

    Posted 9 years ago #

  3. shadow
    Member
    Posted 9 years ago #

    Thanks for the link kafkaesqui but the main reason I am having to do this is because I am having trouble writing to my .htaccess.

    Is there another way of doing this not using .htaccess ?

  4. Kafkaesqui

    Posted 9 years ago #

    If you have access to your server's .conf file...

    Seriously, one way you may be able to this (and still point to the proper theme) is to treat the 404.php in your root as a non-themed but still WP template file by adding this at the top:

    <?php
    define('WP_USE_THEMES', false);
    require(./wp/wp-blog-header.php');
    ?>

    Then to call the various template includes (header, footer, etc) for the active theme, use this format:

    <?php load_template( TEMPLATEPATH . '/header.php'); ?>

  5. Kafkaesqui

    Posted 9 years ago #

    Actually, not thinking deep enough tonight. get_header(), get_footer() and so on will continue to work. So no need for the slightly longer version above.

  6. shadow
    Member
    Posted 9 years ago #

    Thanks Kafkaesqui :)

    I think I may have found an easier solution though.

    Any error pages are directed to my 404.shtml so I have added a quick redirect script there and linked that to a simple error announcement on a static page.

    It seems to work.

    Have a look...

    http://shadows.os42.com/this-page-will-not-work

    Thanks again for your help :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.