Note that there are some explanatory texts on larger screens.

plurals
  1. PORequesting files from another parent directory
    text
    copied!<p>Lets say that we have a server running multiple virtual hosts. Somefiles and directories are shared amongst these virtual hosts, such as JS-, HTML-, and some PHP-files. I want to prevent having to make a new copy of these files every single time we add a new virtual host, since it would make it hard to keep the files up to date. So what I want to do is to put these shared files in another parent directory i.e. /var/www/shared_files/.<br /> So when one of the shared files is requested i.e. <a href="http://example.com/scripts/gallery.js" rel="nofollow">http://example.com/scripts/gallery.js</a> I want to get the file located in /var/www/shared_files/gallery.js instead of /var/www/xxx/gallery.js.<br /> <br /> The first solution I found for this problem was a htaccess solution:</p> <pre><code>RewriteRule ^gallery.js ../shared_files/gallery.js </code></pre> <p>Which only works as long as all the files is requested via the servers IP, i.e. <a href="http://11.11.0.111/xxx/gallery.js" rel="nofollow">http://11.11.0.111/xxx/gallery.js</a>.<br /> <br /> The second solution is a PHP solution:</p> <pre><code>if(* is 404 *) { if(file_exists("/var/www/shared_files/* the requested file name *")) { if(strpos(* the requested file name *, ".js") !== false) header("Content-type: text/javascript"); require_once("/var/www/shared_files/* the requested file name *"); die(); } } </code></pre> <p>This dosnt seem like a good solution in the long run so do anyone know of a better solution for this?</p> <ul> <li>Edited after TerryE's comment</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload