PDA

View Full Version : Redirecting Users


Seb
20-08-2003, 00:25
I currently have two domains registered, lets call then company.com and companyonline.com. The problem is though, that i only have one webspace account.

So here goes:

If a user goes to companyonline.com they are currently forwarded (set up by webhost) to the index page on the webspace. However i would like users to be redirected to a directory on my webspace. I know that i could ask the user which domain name they entered, but thats not very professional for a business website. Therefore i was wandering if any body knows how to sort out this issue, or if there is any free downloads on the net that any one could recommend??

I know that probably doesn't majke too much sense, so i apologise in advance!! Just ask if your not sure, thanks.

Seb

philip.j.fry
20-08-2003, 01:38
I may not be entirely correct in this, but I think that what you need to do is contact your webspace provider and they will then set up their server configuration to forward users to the correct page.

Another way would be to have a script on the initial page to redirect the user to the correct page, you could do this on the server side with something like php or cgi if allowed, or on the client side with javascript.

Richard M
20-08-2003, 02:18
Most decent hosts have got PHP, just put something like this at the start of the index.php file (not tested) :


<?php

$entrydomain = getenv("HTTP_REFERER");

if ($entrydomain = "www.companyonline.com")
{
header("Location: http://www.company.com/site1/");
}

else
{
header("Location: http://www.company.com/site2/");
}

?>

philip.j.fry
20-08-2003, 02:46
or if they don't, use this javascript in the head portion of the first index page (for company.com). Just change the myHostName and correctLoc variables to what you need, make sure to keep the backslashes at the beginning and end of myHostName and put forward slashes in front of any periods.



<SCRIPT language="Javascript">
function reDirect() {

var myHostName = /\.companyonline\.com/;
var correctLoc = "dir/page.html";
var url = window.location.href;
if (url.search(myHostName) != -1) {
document.URL = correctLoc;
}
}
</SCRIPT>



then in the body tags put

<BODY LANGUAGE=javascript onload="reDirect()">

semi-tested

Seb
20-08-2003, 12:25
Cheers all, well I obviously dont have a 'decent' webhost (to be honest I already knew that!!) Yes Demon, you know that small little company ;) , 'do not currently support ASP nor PHP, however their new web platform, due to be released in the next few months will!' So I have had to resort to the javascript from philip.j.fry.

Also I contacted Demon to ask then to set up the web forwarding to a directory on my webspace. 'We are only able to forward the domain to your webspace index page' Right well i'll do the work instead then. I can sense a move of webs hosts :D Has any body got any good suggestions and possibly link?? I'm looking for a host that support more scripting than CGI and Perl!!

Thanks very much for all ya help

Seb

P.S - I see that all of you managed to interprut my post as well, well done to you all.

Richard M
20-08-2003, 14:29
I used www.webfusion.co.uk for a while, they were excellent and their control panel is superb.
A little expensive but well worth it.
I also hear that www.oneandone.co.uk are pretty good too.

KingPhoenix
20-08-2003, 16:49
If your after a new host, checkout I-Web Solutions ::: NTHW Members pricing (http://www.i-websolutions.co.uk/nthwwhosting.html)

Bifta
20-08-2003, 16:58
You could also use something like

<script language="javascript">
if (document.referrer = "http://www.companyonline.com")
location.href = "http://www.company.com/wherever/"; '
</script>