Displaying a different website based on source internet address ?

S

Skybuck

Hello,

Based on the source internet address a different version of the website
should be presented/served to the user/browser.

For example in pseudo code:

if SourceAddress = '143.3.5.1' then
begin
ShowBlueWebsite; // Load/Show BlueIndex.htm
end else
if SourceAddress = '124.5.15.7' then
begin
ShowRedWebsite; // LoadShow RedIndex.htm
end;

Is this possible with java script ? is there any source code available
to do this trick ?

Bye,
Skybuck.
 
T

Tom Cole

document.location.host contains the host portion of the URL (in your
case an IP).

You could use that in a script on your main index page to send a
redirect.

The problem is, what happens if someone without javascript enabled
shows up on your site?

I would recommend having one or the other be default (let's say
index.html is defult and it is the blue page). Then you could put your
script on that blue page. Check the host and if the host is 124.5.15.7
we'll show redindex.html page instead.

So a simple example (this goes in the head section of index.html which
refers to blue page) would be:

<script type="text/javascript">
if (document.location.host == "124.5.15.7") {
document.location = "/redindex.html";
}
</script>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,201
Messages
2,571,048
Members
47,651
Latest member
VeraPiw932

Latest Threads

Top