Here’s a handy tip that I just found. There are a multitude of ways to redirect your WordPress blog temporarily for maintenance. But I recently found myself in a situation where a client needed to be redirected to another site, not just to a holder page (like most plugins do).
Here are the steps:
- Create a file: “wp-content/maintenance.php”. Anything you put here will be displayed for logged-out users. (Thanks to Matt Sivel who pointed this out).
- Once inside that file, copy and paste this code: (don’t forget the php tags)
header( 'Location: http://www.redirectedSite.com' ) ;
Now your WordPress blog should be forwarding to the new location when you’re not logged in, but staying on your site when you do login.
hassan says
Hi,
Puth this code in functions.php page in end of this page and add broken link url and add your website url.. hope it helps for visitors.
Thank
function curPageURL() {
$pageURL = ‘http’;
if ($_SERVER[“HTTPS”] == “on”) {$pageURL .= “s”;}
$pageURL .= “://”;
if ($_SERVER[“SERVER_PORT”] != “80”) {
$pageURL .= $_SERVER[“SERVER_NAME”].”:”.$_SERVER[“SERVER_PORT”].$_SERVER[“REQUEST_URI”];
} else {
$pageURL .= $_SERVER[“SERVER_NAME”].$_SERVER[“REQUEST_URI”];
}
return $pageURL;
}
$pageurl=curPageURL();
//PHP conditional statement to test equality of current URLs
if ($pageurl==”http://www.php-developer.org/thisismypage/”)
{
//Permanent redirection if URL match with requested URL
header(“HTTP/1.1 301 Moved Permanently”);
header(“Location: http://www.php-developer.org/“);
exit();
}
?>
Anonym says
Ohhh my fg..
so simple ;D
all the day searching , google, and find!
Tanks dude