Dynamically restrict accesses to virtual hosts' documentroots
| From: | Ole Tange | Date: | Thu, 17 Jan 2002 02:53:47 +0000 |
| Subject: | Dynamically restrict accesses to virtual hosts' documentroots | ||
| Groups: | php.install | ||
| Request: | Send a blank email to php-install+get-5606@lists.php.net to get a copy of this message | ||
I have a lot of virtual hosts. They are made with rewrite-engine so they
do not each have a <VirtualHost> section.
I would like for PHP to restrict access from PHP to $DOCUMENT_ROOT. Also I
would like to have / mean $DOCUMENT_ROOT.
This means that if http://www.example.com/foo/bar.php opens a file called
"/fubar.html" then this file will be the same as:
- http://www.example.com/fubar.html
- $DOCUMENT_ROOT/fubar.html
- /home/of/www.example.com/public_html/fubar.html
www.example.net lives on the same machine.
If http://www.example.net/baz/xyzzy.php opens a
file called
"/quux/quuux.txt" then this file will be the same as:
- http://www.example.net/quux/quuux.txt
- $DOCUMENT_ROOT/quux/quuux.txt
- /home/of/www.example.net/public_html/quux/quuux.txt
What I am looking for is something that smells like chroot without
actually being it. It should be so dynamically because it will be
impossible to make all the <VirtualHost>-statements as VirtualHosts are
generated dynamically with the rewrite-engine.
I have looked into doc_root and it seems to do part of the trick - though
only statically. What I need is dynamically.
I am looking for a way to say:
doc_root = $DOCUMENT_ROOT (Calculated for each request. Not at boot time)
and prepend $DOCUMENT_ROOT to the file name for each file access that
starts with '/'.
I am sure others that host a lot of virtual hosts have the same problem,
but I have not been able to find the solution.
/Ole