Forum Moderators: coopster

Message Too Old, No Replies

Broken path in URLs

broken path in URLs

         

Tourex

8:44 am on May 17, 2005 (gmt 0)

10+ Year Member



If I enter "http://www.mydomain.com/page.php/" in my browser, I get the page but the images don't display and indicate broken links. If I call the page normally, (i.e. "www.mydomain.com/page.php"), then everything displays correctly.

Can someone please explain to me what is happening, why the relative links are broken and how I code these pages to allow them to be displayed properly under either circumstance. The page is using relative paths for the images (in this case "src="../images/#*$!xx").

I'm not sure yet where the calls to page.php/ are coming from, but I obviously want them to display correctly.

Thanks.

krt1

11:09 am on May 17, 2005 (gmt 0)

10+ Year Member



You can use absolute paths and if you want to keep portability, then save the path to the main site files to a variable and prefix links with that
eg.
<?php
$path = '/site/';
?>
<img src="<?php echo $path;?>images/boo.gif" ...

Or you can use mod_rewrite to redirect the user to the correct file.

RewriteRule ^page\.php\/$ page.php [R=permanent,L]

Tourex

4:08 pm on May 17, 2005 (gmt 0)

10+ Year Member



Thanks for that. I think I understand what you're saying (sorry, I'm new to this)

There are two problems. I am using a page for search engine listing purposes, which provides a list from a MySQL database, using the 'friendly' address, /page.php/P/375 to that engines who don't like the? will index the entire site. So, I imagine that your mod-rewrite solution, although the neatest, would block these pages (wouldn't it?).

Secondly, the biggest problem with a solution in the web pages is that I'm authoring on a Windows platform and the site is hosted on Linux. I need to find a solution that allows me to see and work on the graphics/illustration on my local machine while editing which I believe isn't possible with the code you suggest. Or am I misunderstanding what I have to do?

Thanks for your input and suggestions though and hopefully you can put me straight.

Tourex

5:15 pm on May 17, 2005 (gmt 0)

10+ Year Member



I've found something on this, which takes it WAY beyond my knowledge and experience.

I did a test page which includes phpinfo() and ran it by calling test.php and test.php/

The Apache Environment table has two extra rows on the info for test.php/ - The first new entry is 'PATH_INFO' which shows '/' and 'PATH_TRANSLATED' which shows the Linux path to the root of the web '/home/vhost/domain.com/html/'

Now, I'm not sure what this proves or means, but it would seem to me that the page 'thinks' its in a different directory when the page is called as test.php/ and so isn't finding the relative paths to the image files. I'm hoping that there's a fix to this, or at least a workaround - such as a piece of php code I can slap into the top of the page so that it corrects the situation.

All help gratefully received. Thanks.