phpopen-basedir

Access main domain files in Subdomain


Lets say i have domain.com and five other subdomains.

The subdomains are stored in separate folders from domain.com

In domain.com i am going to have 3 folders that i need to access when i am in other subdomains, i'm going to be accesing php, css, images, any stuff.

Each subdomain needs to have their own htaccess.

What is the best approach to do this? i've read something about open basedir, but i'm not exactly sure if this is the best way to do it or not. And neither how it works.

Thanks in advance


Solution

  • If it's on a different server, you could use the .htaccess file to proxy the requests to the original domain (if you have mod_rewrite and mod_proxy enabled).

    RewriteRule ^images/(.*)$ http://www.example.com/images/$1 [P]
    

    If it's all on the same server:

    1. Use symlinks (if it's on Linux/Unix/OSX) to create symbolic links to the other images folders. From the shell use ln -s /path/to/images /path/to/subdomain/images. See the man page for ln for more information.
    2. If you have mod_alias enabled, you could use: Alias /image /path/to/images in your .htaccess or httpd.conf.