PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Can you do this at the domain level? I know with godaddy you can set a domain forward instruction for a particular domain name and retain the entered URL in the address bar.
I think you are at the very least going to need to have a .htaccess file somewhere that will route all incoming requests to a particular page, then that page would have to handle the redirects. Normally I would say do this on the server, but since you don't have access, you will need to do this with .htaccess.
My next question is how do you have your server configured at the moment? Are requests to first.com and second.com handled on each virtual server or is there a single server that is serving all requests to both those domains?
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I've added your suggestion and when I type http://www.first.com I get
<!-- URI is -->
in the source. That's all.
Same exact thing when I type http://www.second.com
This is what my index.php is looking like right now (I've tried changing the "URI" to "URL" but nothing changes):
<?php
echo '<!-- URI is ' . $_SERVER['REQUEST_URI'] . ' -->';
if ($REQUEST_URI == "http://www.first.com")
{
header('location: http://www.first.com/index2.htm');
}
else if ($REQUEST_URI == "http://www.second.com")
{
header('location: http://www.second.com/index3.htm');
}
?>
Please, remember that first.com is the original domain. Second.com is aliasing right now to first.com. So without a redirect page, both domains are going to the same index page. I need them to both hit index.php and then take separate paths maintaining the domain they have entered index.php with.
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I hope this is what you were asking for. I've x'd out the domain name, but it's always first.com on this list (never second.com), just in case you need that info.
<?php
if ($_SERVER['HTTP_HOST']="www.first.com") {
header("location: http://www.first.com/index2.htm");
} else if ($_SERVER['HTTP_HOST']="www.second.com") {
header("location: http://www.second.com/index3.htm");
}
?>
Now what happens here is no matter if I type first.com or second.com it goes to http://www.first.com/index2.htm.
I guess it doesn't read the second part of the redirect.
Please remember that right now second.com is an alias domain name, that is directed at first.com.
So how can I make that second part work and have anything directed at second.com redirect to second.com/index3.htm? (index2.htm and index3.htm are in the same folder, because of the aliasing).
Also, remember that I don't know PHP so understand if my syntax is completely wrong.