files outside document root

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rhecker
Forum Contributor
Posts: 178
Joined: Fri Jul 11, 2008 5:49 pm

files outside document root

Post by rhecker »

I have websites with the following directory structure:

public_html/site1
/site2
/css
data_access

In the above scenario, the domain name site1.com points to /site1 and site2.com points to /site2

PHP can access the files outside the document root with a path like "../../data_access/file.php

. . .but I need to share CSS files and other files outside the document roots, and HTML doesn't allow this.

The server is a VPS, so I have a lot of control, and I'm sure there is a way, but I don't know what it is.

Meanwhile, I am researching various options. Security is a serious concern. It looks like symlink might create a vulnerability.
Any help?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: files outside document root

Post by Christopher »

Use symbolic links:

ln -s /path/to/public_html/site1/css /path/to/public_html/site2/css
(#10850)
rhecker
Forum Contributor
Posts: 178
Joined: Fri Jul 11, 2008 5:49 pm

Re: files outside document root

Post by rhecker »

Thanks Christopher. I ended up using Alias, which works on the VPS but just won't work on my windows 7 machine. This is what I have.

<IfModule alias_module>
Alias /css_shared "D:/Apache2/htdocs/site/css"
</IfModule>
<Directory "D:/Apache2/htdocs/site/css">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
Post Reply