homepage Welcome to WebmasterWorld Guest from 54.196.196.108
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Incorrect path
file_get_content gives wrong link path
Rhys




msg:3224155
 8:46 pm on Jan 18, 2007 (gmt 0)

I am trying to embed an AStore in a page without using ifames (so as to get content spidered).

Using file_get_content('ht*p://offsite.com/login/'); works fine, except that all the internal links then point to the containing page, not the target.

The target links should read ht*p://offsite.com/linked_page/ but instead they all construe to ht*p://mysite.com/linked_page/ and results in an "Object not found!" error.

 

jatar_k




msg:3224352
 12:35 am on Jan 19, 2007 (gmt 0)

I am guessing they are all relative links, which means they will always point to whatever site they are on. When you include the file the paths look locally unless the links include the fully qualified uri.

If you want to replace them you would have to add the site in before the links.

you could try replacing

href='

with

href='http://www.offsite.com

using
[php.net...]
or
[php.net...]

Rhys




msg:3224470
 3:19 am on Jan 19, 2007 (gmt 0)

That's exactly what I did Jatar and it works perfectly

$show_shop = file_get_contents ('ht*p://astore.amazon.com/login-20/');

$show_shop = str_replace("\"/login-20/","\"ht*p://astore.amazon.com/login-20/", $show_shop);
echo $show_shop ;

Now the shop appears at it's own URL and page, and the links are all rewritten from relative to absolute.

The only problem now is that aStore reverts to the Amazon site whenever a link is clicked - but that's a whole new challenge!

jatar_k




msg:3224477
 3:22 am on Jan 19, 2007 (gmt 0)

hehe, nice work Rhys

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved