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?