I have a Linux server with Apache2 as its web service. I want to redirect two sites pointed to that server to other two websites. At first I was confused how to do that as I work in networking section. Later I got help anyway and I am going to share the solution with you.
First I have to change default page 'index.html' to 'index.php'.
Then I have given below code to redirect those to two sites to another two websites.
##################################
<?php
$actual_link = "$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
if($actual_link == "www.xyz.com/")
$redirect_page = "http://www.anotherone.com/";
if($actual_link == "web2.xyz.com/")
$redirect_page = http://www.anothertwo.com/;
?>
<html>
<head>
<meta http-equiv="refresh" content="3;url=<?php echo $redirect_page ?>" />
</head>
<body>
<h1>Please wait, You are redirecting... </h1>
</body>
</html>
#################################
I am happy with this simple solution. You??
First I have to change default page 'index.html' to 'index.php'.
Then I have given below code to redirect those to two sites to another two websites.
##################################
<?php
$actual_link = "$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
if($actual_link == "www.xyz.com/")
$redirect_page = "http://www.anotherone.com/";
if($actual_link == "web2.xyz.com/")
$redirect_page = http://www.anothertwo.com/;
?>
<html>
<head>
<meta http-equiv="refresh" content="3;url=<?php echo $redirect_page ?>" />
</head>
<body>
<h1>Please wait, You are redirecting... </h1>
</body>
</html>
#################################
I am happy with this simple solution. You??
No comments:
Post a Comment