views:

15

answers:

1

On my server, a website resides within a directory similar to /domains/domain.com/public_html. I wish to keep the domain at this path, as all the main files are there, but is there any way to source some files from another location in my server, eg. /global/script.js?

In short, I hope to write a mod-rewrite than can source specific files from outside the DocumentRoot, or something very similar, but I cannot work out a solution.

I figure I could manage this by directing all files to a PHP script (css, js, php, images, etc), which will then work out what file is requested, load the files contents and return it with the correct header. I feel this will more than likely slow down all requests because I believe this requires more processes, is this correct?

+2  A: 

No need for mod_rewrite: If all files are in the same directory, you can use alias.

Alias /MyMapDir /global/resources

a request to example.com/MyMapDir/script.js will be mapped to /global/resources/script.js

Note that this works in httpd.conf only!

Pekka
Thank you I will give the Alias a shot, but I fear my live server may not allow this (I know I can play with it in my local WAMP though)
Rhys
@Rhys as far as I know, there is no way of doing this if you don't have access to the server configuration. Everything possible in `.htaccess` files seems to be limited to the `VirtualHost` in question but can't point beyond. An alternative may be creating symbolic links that point to the global directory
Pekka