Linking to URL on request URL of an iFrame within a page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nitreb
Forum Newbie
Posts: 2
Joined: Wed Aug 06, 2008 10:25 am

Linking to URL on request URL of an iFrame within a page

Post 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 ;)
Last edited by RobertGonzalez on Wed Aug 06, 2008 1:37 pm, edited 1 time in total.
Reason: Made the post title make sense since the original title was pretty bad
User avatar
chaos
Forum Newbie
Posts: 22
Joined: Thu May 15, 2008 9:20 am
Location: New Jersey

Re: Help with code....

Post 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 } ?>
dajawu
Forum Commoner
Posts: 59
Joined: Fri May 23, 2008 10:16 am

Re: Help with code....

Post 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.
nitreb
Forum Newbie
Posts: 2
Joined: Wed Aug 06, 2008 10:25 am

Re: Help with code....

Post 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...
User avatar
chaos
Forum Newbie
Posts: 22
Joined: Thu May 15, 2008 9:20 am
Location: New Jersey

Re: Help with code....

Post 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.
Post Reply