I'm trying to configure a system like so:
client requests external page from my site -> my site requests page from the site ->returns the external page to the user
I'm using file_get_contents to do this.
The only problem is, if they click a link, it brings them to the page relative to MY site, not the requested site. IE, if they click a link to a youtube vid which usually reads 'youtube.com/12412412' it brings them to 'mywebsite.com/youtube.com/1214141'.
I thought that perhaps using an Iframe was the way to go, but do Iframes work through the server or just request the page from the client side?
Either way, I'd like a way to at least make pages' links work.
iframe / file_get_contents
Moderator: General Moderators
-
Cucumberdude
- Forum Newbie
- Posts: 14
- Joined: Sun Dec 12, 2010 11:53 pm
Re: iframe / file_get_contents
an iFrame will work just fine, you can click on any link in an iFrame and it will be on that website not yours.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: iframe / file_get_contents
iframes are nothing more than a new window embedded in your active window. It is entirely client side and will never touch your server side.
If you want to simulate the same behavior with file_get_contents(), you need to rewrite your url's in the header to point to your domain, and have your application handle the new links appropriately. I.e.,
http://google.com
Would become http://yourdomain.com/your_script.php?p ... google.com (or something down this line).
From there, you need to check whether $_GET['page'] is an absolute url, or a relative url (and if so, prepend the hostname information).
If you want to simulate the same behavior with file_get_contents(), you need to rewrite your url's in the header to point to your domain, and have your application handle the new links appropriately. I.e.,
http://google.com
Would become http://yourdomain.com/your_script.php?p ... google.com (or something down this line).
From there, you need to check whether $_GET['page'] is an absolute url, or a relative url (and if so, prepend the hostname information).