Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grab URL from address bar and redirect depending what is typed

Status
Not open for further replies.

sc0rp9

Technical User
May 16, 2002
7
0
0
GB
Hello

I wonder if any of you can help me please, I'm running a web server on IIS and have a dynamic IP address.

Domain names are forwarded to link to where the following code lives and its supposed to forward users to my server depending on the URL they typed (this way I can map all domains to the same site), and in theory the following Javascript would redirect to the correct address.

I have tried the following but cannot get it to work, any chance of some help please. (by the way I also tried document.referrer, document.location & URL in a similar context to the following code but all I get is the top level domain no matter what is typed)

Heres the code:

function redirect()
{
var x;
x = "80.0.182.0";

if (location.href ="{location.href=" + x + "/";}
else if (location.href="{location.href=" + x + "/site2/";}
else if (location.href="{location.href=" + x + "/site3/";}
}

Thanks in advance for your help

Regards
Sc0rp9
 
Hi anupamkant

I was going to use one of the free sites as a re-direct beacon and they don't support this type of coding but what you put there sounds like it may do the job, is it ASP, as I may get away with CGI or similar. but would prefer a JS solution

Regards
sc0rp9
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top