• etrader

    (@etrader)


    What is the easiest way to redirect visitors to the main website url when they visit a page that does not exist. I mean instead of showing a 404 error page, redirecting them to the main page/

Viewing 1 replies (of 1 total)
  • henkholland

    (@henkholland)

    Etrader,

    In my index.php if have this:

    <?php if (have_posts()) : ?>
    
    <?php while (have_posts()) : the_post(); ?>
    
    <div class="post" id="post-<?php the_ID(); ?>">
    
    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
    
    <p class="postmetadata">
             <?php the_time(__('j F Y - H:i')); ?><?php edit_post_link('Edit', ' | ', ''); ?>
    				</p>
    
    <div class="entry">
    <?php the_content('.. lees meer ..'); ?>
    </div>
    <div style="clear:both;"></div>
    </div>
    
    <?php endwhile; ?>
    
    <div class="navigationcontainerbottom">
    			<div class="containerbottomtextalignleft"><?php next_posts_link('&laquo; Oudere berichten') ?></div>
    			<div class="containerbottomtextalignright"><?php previous_posts_link('Nieuwere berichten &raquo;') ?></div>
    </div>
    
    <?php else : ?>
    
    <h2>Blimey</h2>
    <p>Something went wrong. Please contine through the menu at the left hand side.</p>
    
    <?php endif; ?>

    Note the stuff after the php else
    I have no 404.php and nothing for errors in my.htaccess.

    Result: every error shows my front page with the error text above in my blog area of the front page and everything else like the normal frontpage.

Viewing 1 replies (of 1 total)
  • The topic ‘Redirecting to the main page instead of 404 error’ is closed to new replies.