Hello,

Could someone suggest me the ways to redirect a website from one server to another website in another server?

I have one website "X" (IP based e.g http://x.x.x.x/example.html) in one server using IIS and another website "Y" (domain based e.g. www.abc.com ) on another server using Apache. I linked the website X to Y by providing a link for X in Y. Right now, after clicking on the link, it shows the public IP address of X in the address bar. However, I would like to display the web address as www.abc.com/example.html rather than IP address.

Your suggestions are gratefully appreciated.

I suggest you use AJAX. I've already encounter that same problem. I use ajax into my javascript.
I direct the url of the website "one" to the website "two".

/*example*/

$.ajax({
type:"POST",
url:"server/fromServerX.php?action=viewServerY",
success: function(msg){	
  // your code here
}

});

You may place before any html/browser output the following function.

<?php

header('Location: http://www.example.com/'); //redirects user
/*
no echo's print's or ?> before here and <?php starts at the
beginning of the file before here as shown so this may be
in an if statement to check if the user get's redirected.
*/

following code is fine

header('Location: http://www.example.com/'); //redirects user
exit;

you can ask your server administrator HOW TO SET DNS property. They might help you to map ip<->domain.

Thank you for your replies. Now, I solved my problem. I am writing the solution that I made for my case so that it may help others.

I made one example.html page in server X (IP Based) that is running with IIS and another file example.php with the following code in the Server Y (domain based)that is running with Apache. Now, I am able to link IP based (e.g x.x.x.x/example.html) file with the domain www.abc.com/example.php instead of IP address.

example.php

<?php
readfile("http://x.x.x.x/example.html");
?>

You dont actually need any coding... all you need to do is change the DNS records on the server where your domain name lies, so that the DNS records store the IP addresses of the server you want it to direct to.

If you contact your web hosting provider they will be able to sort this out for you in 2 minutes flat, it will direct people to your website address rather than needing the IP address, and its the easiest thing in the world.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.