Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I noticed that if you go to lostlettermen.com/aa, it redirects to a post. Is this a feature in WordPress that can be turned off, or is this done by some type of plugin or custom code?

share|improve this question
    
custom code query –  xLRDxREVENGEx May 24 '11 at 15:41
add comment

migrated from stackoverflow.com May 24 '11 at 12:09

This question came from our site for professional and enthusiast programmers.

1 Answer

This is done by redirect_guess_404_permalink(), which is called from redirect_canonical(). redirect_canonical() does more than just this: it makes sure you are always using a single canonical URL for an item, it will add slashes, force the same domain name, ...

You can either unhook redirect_canoncial so it does nothing, or you can hook into it and prevent redirection when it is a 404:

// Disable redirect_canonical()
add_action( 'init', 'wpse18110_init' );
function wpse18110_init()
{
    remove_action( 'template_redirect', 'redirect_canonical' );
}

// Only prevent redirect on 404
add_filter( 'redirect_canonical', 'wpse18110_redirect_canonical' );
function wpse18110_redirect_canonical( $redirect_url )
{
    if ( is_404() ) {
        return false;
    }
    return $redirect_url;
}
share|improve this answer
    
nice! didn't know about the redirect_guess_404_permalink() –  MZAweb May 27 '11 at 19:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.