Log in

View Full Version : Redirect question



noahvale
01-14-2007, 07:26 AM
This is my first post here. Great site, I've learned a lot here.
I have a domain that is pointed to another domain that I host. Is there a way in html to redirect someone based on the url that they came to the site from?
Specifically my domain http://electrimate.com is pointed to my other domain http://bayoucables.com. I would like anyone who comes to the site with the electrimate url to be redirected to a page in a directory in the bayoucables.com site. I get the redirect service way cheaper than having a separate host for it...

chechu
01-14-2007, 03:36 PM
Just place the following in the page that you want to forward to the other.
Fill the name of the destination page in the code:


<meta http-equiv="redirect" content="1;url=http://www.destination.com">


Is that what you were looking for ?

thetestingsite
01-14-2007, 04:06 PM
Just place the following in the page that you want to forward to the other.
Fill the name of the destination page in the code:


<meta http-equiv="redirect" content="1;url=http://www.destination.com">


Is that what you were looking for ?

Just a note, place it between the head tags in the html document.

noahvale
01-14-2007, 04:52 PM
No that's not it. My website bayoucables.com is also electrimate.com.
I want just the folks that come to the url electrimate.com to be redirected, not the ones that come to bayoucables.com. So what I need is some code that will parse the url that the user is using to get to the site.
Thanks.

thetestingsite
01-14-2007, 05:16 PM
if you have php enabled on your server, you could do it that way. But if you want just the electrimate.com visitors to be redirected, make a file (lets call it index.html) and place the following code in it:



<html>
<head>
<meta http-equiv="redirect" content="0; url=http://www.bayoucables.com">
</head>
<body>
If you are not redirected automatically, click <a href="http://www.bayoucables.com">here</a>.
</body>
</html>


Just put this on the site electrimate.com and not bayoucables.com.
Hope this helps.

noahvale
01-14-2007, 06:59 PM
Yes, I have php available.
That's close, but not quite, let me explain it a little further.
If you go to http://electrimate.com, the name server actually sends you to http://bayoucables.com's server page. It says it's electrimate.com, but it's actually bayoucables.com. I have a link at the top of the main page for electrimate.com that sends you to a directory on the bayoucables.com page that contains the electrimate pages. I just want a way to redirect based on the url that the user entered the site with.

thetestingsite
01-14-2007, 07:08 PM
Try this:



<?php

if ($_SERVER["HTTP_HOST"] == "electrimate.com" || $_SERVER["HTTP_HOST"] == "www.electrimate.com") {

header('Location: http://bayoucables.com/electrimate.com/');

}

?>


That should do it.

noahvale
01-14-2007, 08:26 PM
By jove, I think he's got it!
That works great. I put that at the beginning of my html index file and then I had to rename the index.html to index.php.

Thank you very much!