Question

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

Was it helpful?

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.

OTHER TIPS

if you don't want to go through the stress of editing .htaccess or you dont have shell access, then just use URL paths for resources like images e.g. "http://example.com/images/prev.png" for include files you can use absolute paths "/home/example/public_html/inc/test_subd.php"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top