Re: Can't find the server path when, in http.conf, using Alias and DirectoryIndex

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Paul Gardiner wrote:
I want to write a simple indexing script to display a
directory full of photos as a gallery of thumbnails.
(There are various solutions out there for this, but
they're all a bit more complicated than I need).

I've added a file in /etc/apache2/conf.d that
looks like this:

Alias /photos /home/public/photos
<Directory "/home/public/photos">
    AllowOverride None
    Order allow,deny
    Allow from all

    DirectoryIndex /cgi-bin/index.php
</Directory>


I use "Alias" so that I can leave the photos where they are
and not have to move them to DocumentRoot. I use "DirectoryIndex"
so that the script doesn't have to be in with the photos. My
problem is that the running script seems to have no way to
work out the photos are in /home/public/photos.

$_SERVER[REQUEST_URI] is "/photos/", but I can't see how to
derive the server path from that, since $_SERVER[DOCUMENT_ROOT]
is "/srv/www/htdocs".

$_SERVER[PHP_SELF] is "/cgi-bin/index.php", so no use either.


How can I do this? Is there a way to interrogate the alias,
or can I set a variable in the conf file that PHP can pick up?

I've sussed it. If I use this apache2 conf file, where I
tag the server path onto the end of the index url:

Alias /photos /home/public/photos
<Directory "/home/public/photos">
    AllowOverride None
    Order allow,deny
    Allow from all

    DirectoryIndex /cgi-bin/index.php/home/public/photos
</Directory>

then the script can pick up the path as $_SERVER[PATH_INFO]

P.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux