[Gllug] php, Apache and relative paths.

Simon Stewart sms at lateral.net
Mon Jan 21 11:35:55 UTC 2002


On Sun, Jan 20, 2002 at 10:38:56AM +0000, Lucy Bartosik wrote:
> In php scripts I am unable to use relative paths for links in the
> password protected area.  I therefore have to put the full path in which
> will slow matters down considerably.

Which sort of relative paths? PHP and a web server have very slightly
different ideas about what "relative" means, though the idea is the
same. PHP takes paths from the actual filesystem of the box that it's
running on, allowing you to keep things such as database includes in a
seperate place outside of the htdocs tree. A relative path from a
served web page is relative to the DocumentRoot.

That appears to be nonsense, so perhaps an example would help:

>         </Directory>
>         <Directory /var/www/ukadis/htdocs/secure>
>         AuthName "UKADIS Members area"
>         AuthUserFile /var/www/ukadis/ukadis.htaccess
>         </Directory>

>From this, it looks like the DocumentRoot of the site probably points
to "/var/www/ukadis/htdocs/" (that is, the secure area is reached by
going to "http://somewhere.co.uk/secure/")

So:

----- PHP page

<html>
<head><title>Example missing out sgml doctype</title></head>
<body>

<!-- This link points to /var/www.ukadis/htdocs/secure/page.html -->
<p>This is a <a href="/secure/page.html">link</a>

<? 
// Whereas this points to exactly where it says on the local FS
include "/secure/page.html"; 
?>

</body>
</html>

----- end PHP page

Does that help any?

Cheers.

Simon

-- 
Misspellers of the world untie!

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list