WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Redirect to main page (7 posts)

  1. diabolus
    Member
    Posted 6 years ago #

    hi....

    i've searched around this forum but still can't get the answer. so, i wanna redirect the error 404 to main page, and not to 404 page of wordpress theme. please tell me.

    any help would be highly appreaciated

  2. Outrix
    Member
    Posted 6 years ago #

    open 404.php file at your theme and replace code by the following:

    <?php
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: ".get_bloginfo('url'));
    exit();
    ?>
  3. moshu
    Member
    Posted 6 years ago #

    Deleting the theme's 404 file doesn't do exactly that?

  4. diabolus
    Member
    Posted 6 years ago #

    thanks, but my wordpress theme does not have 404.php file ! the 404 error controlled through code something like below:

    <div class="contentbody">
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    </div>

    ...it exist in the index.php file of my wp theme.

  5. moshu
    Member
    Posted 6 years ago #

    Actually, I don't think that's a "404" error. It's more like an invalid query inside WP.

    You get a 404 when a file is not where you are looking for; e.g. yourblog.com/moshu.html

  6. diabolus
    Member
    Posted 6 years ago #

    moshu,

    i mean exactly like in your site, when i requested a page that does not exist like:

    http://wp101blog.info/diabolus

    ..then i get message:

    Not Found
    Sorry, but you are looking for something that isn't here.

    it exactly happened in my blog. so i want when typing :

    http://wp101blog.info/diabolus (a page that does not exist)

    then i/we will be redirected to main page: http://wp101blog.info

    ..and these message, of course, will not be appeared.

    so please tell me?

  7. diabolus
    Member
    Posted 6 years ago #

    Resolved :)

    i get the right advice at Stop Losing Visitors to 404 Error Pages

    ...using .htaccess ! sorry for this stupid poblem, but thanks alot for reading this post :))

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.