Page 1 of 1
Linking to URL on request URL of an iFrame within a page
Posted: Wed Aug 06, 2008 10:27 am
by nitreb
Hey you guys Im trying to have a link with dual locations, what I mean is basically I want a link that sends people to a certain location base on where they are. I have an application that's on two different websites, so what the code would do is check the url, and base on which url the user is on, it would send them to the right location.
Please let me know if that can be done, and if any of you guys have a code for that...
I have no knowledge of php, so if you guys have one could you please give it to me....
tx in advance

Re: Help with code....
Posted: Wed Aug 06, 2008 10:37 am
by chaos
Code: Select all
<?php if($_SERVER['SERVER_NAME'] == 'some.example.com') { ?>
<a href="somelink">somelink</a>
<?php } else { ?>
<a href="someotherlink">someotherlink</a>
<?php } ?>
Re: Help with code....
Posted: Wed Aug 06, 2008 10:45 am
by dajawu
Without knowing to many details, I see that you don't know PHP so I am guessing you don't have it on either of these two sites. So PHP aside what I do is very basic. I have one site on 4 different domains and I make my links without using the domain name so they will work no matter what domain they are under. If you want to go to a page like test.htm on your site link it like this:
<a href="test.html">Test</a> instead of <a href="
www.domain.com/test.htm">Test</a> that way it will go to test.html under whatever domain it happens to be located on. If this isn't what your talking about, write back with more details of what you need.
Re: Help with code....
Posted: Wed Aug 06, 2008 12:01 pm
by nitreb
Chaos you got the idea, but there's one problem, my site is actually an application on two different sites through iframe, so it's under one server name...
Could you do a code that checks the url of the site that the application is on?
Dejawu, the chaos gave me, is sort of what im looking for....
tx...
Re: Help with code....
Posted: Wed Aug 06, 2008 12:28 pm
by chaos
Hmm. Perhaps you could check $_SERVER['HTTP_REFERER'] instead. I'd say test that by echoing it and seeing if it gives you something usefully different in the iframe/non-iframe contexts.