Reply to Re: relative path / absolute path

Your name:

Reply:


Posted by David Haynes on 06/18/06 10:35

Jerry M. Gartner wrote:
> Greetings:
>
> What is the best way to resolve paths within a document regardless of what
> path it is opened under? For example: I have x.php and it contains <img
> src="images...">, (amongst other things, like php code), which resolves the
> correct image path when opened under / but when x.php is read into a file
> under /dir the image no longer resolves, for obvious reasons. With absolute
> paths, this isn't an issue but it is with relative paths. Although I can
> think of a kludge, or two, I figure that there is a more elegant solution.
> Thanks in advance.
>
If I understand you correctly, this is really a web server issue and is
handled by the 'Alias' function in Apache (other servers may call it
something else). This function allows you to set a path prefix - say,
/images - and have all references to an image resolve to the same place.

So in your code you would have <img src="/images/foo.gif"> and it would
resolve to /my_web/images/foo.gif regardless of where it was referenced
in your web document tree.

Aliases may also be used for css, javascript or any other commonly
shared code elements.

Hope this helps.
-david-

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация