3

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

Peibol
  • 147
  • 4
  • 12

2 Answers2

5

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"

Kudehinbu Oluwaponle
  • 1,045
  • 11
  • 11
1

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.
Francois Deschenes
  • 24,816
  • 4
  • 64
  • 61
  • SymLinks, cool thats an approach i hadnt think of. But im editing my website in Windows, is there something similar I could use in windows? - Im going to try Alias in httpd, thanks a bunch. – Peibol Jun 18 '11 at 01:49
  • @Peibol - If you're using Apache on Windows, you can enable mod_alias and use the second suggestion. You could also proxy the requests with mod_rewrite or mod_proxy. I'm on OSX but I Googled "symbolic link windows" and came across [this](http://www.howtogeek.com/howto/windows-vista/using-symlinks-in-windows-vista/), [this](http://answers.google.com/answers/threadview/id/341355.html), [this](http://msdn.microsoft.com/en-us/library/aa365680(v=vs.85).aspx) and many more. I'm not sure if Apache on Windows will honour them but give it a try. – Francois Deschenes Jun 18 '11 at 01:52