Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Enhance your 404 page

<?php
$redirect_301 = array(
'/ddd/' => '/forum/newlocation',
);

list( $request, $query ) = explode( '?', $_SERVER['REQUEST_URI'], 2);
$request = rtrim( $request, '/' );

$forum = dirname( $_SERVER['PHP_SELF'] );

foreach( $redirect_301 as $from => $to ) {
$from = $forum . '/' . trim( $from, '/' );
if( $from != $request )
continue;
if( !empty( $query ) )
$to .= '?' . $query;
wp_redirect( bb_get_uri ( $to ), 301 );
exit();
}

?>

That might support IIS, the native WP function doesn’t use the Location: header so I guess that’s an issue?

http://support.microsoft.com/kb/q176113/

@chandersbs: It’s nice :D I tidied it up to support trailing slashes no matter what and query strings amongst other things. I think. That or it’ll break :D

I dropped the need to have the forum directory included in the $redirect_301 array as well, that’s automatically added now. Just change bb_get_uri ( $to ) to $to if you need to point the redirect outside the forum directory or use ..

Skip to toolbar