• Resolved MindReality

    (@mindreality)


    I want to redirect to homepage instead of displaying the page not found message. How do I do that?

    Is there a function in the index.php where I can call to redirect to the Homepage instead of displaying the page not found message?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Just remove the 404.php file from your theme, or make your 404.php file have only this line in it:

    <?php wp_redirect(get_option('home')); ?>

    Thread Starter MindReality

    (@mindreality)

    Hi, I placed the code in the index file of my theme folder.

    <?php endwhile; else: ?>
    <?php wp_redirect(get_option(‘home’)); ?>
    <?php endif; ?>

    But I get this error:

    Warning: Cannot modify header information – headers already sent by (output started at /home/mindreal/public_html/wp-content/themes/greenmarinee/header.php:5) in /home/mindreal/public_html/wp-includes/pluggable-functions.php on line 247

    Read again what was posted as an answer to your question!

    In other words, that line will not work in the middle of the index.php file.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Redirect page not found to Homepage’ is closed to new replies.