Quickly Add a Single 301 Permanent Redirect to WordPress

By michael  |  June 22nd, 2010  |  Published in WordPress  |  1 Comment

Alan Knox, the developer of our FacePress plugin that automatically publishes WordPress posts to Facebook recently left FullThrottle to start his own Web Design company. We’re really excited about where he is going and about the sites that he already has in development.

When he left, we mutually agreed to send his FacePress plugin with him (its his baby and he’s best qualified to support and enhance it). In doing so, we needed to create a permanent 301 redirect for the support page but we didn’t want to install a plugin that included an admin panel, etc. Instead, we elected to put this short code in our theme’s functions.php file.

Please feel free to take and modify as needed. Only one condition: if you have a way to improve this, please share in the comments!

// Permanantly Redirect FacePress Plugin
function permanent_301_redirect_facepress() {
	if ( isset( $_SERVER['REQUEST_URI'] ) && '/facepress-ii' == $_SERVER['REQUEST_URI'] || '/facepress' == $_SERVER['REQUEST_URI'] ) {
		header( 'HTTP/1.1 301 Moved Permanently' );
		wp_redirect( 'http://knoxwebdev.com/facepress-ii' );
		exit();
	}
}
add_action( 'template_redirect', 'permanent_301_redirect_facepress' );

Test it by going to http://fullthrottledevelopment.com/facepress-ii!

Responses

  1. Php Web Development says:

    August 17th, 2010 at 3:14 am (#)

    Nice article help me lots Thanks keep it up