Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7534599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:04:04+00:00 2026-05-30T06:04:04+00:00

Lets say that we have a server running multiple virtual hosts. Somefiles and directories

  • 0

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/.
So when one of the shared files is requested i.e. http://example.com/scripts/gallery.js I want to get the file located in /var/www/shared_files/gallery.js instead of /var/www/xxx/gallery.js.

The first solution I found for this problem was a htaccess solution:

RewriteRule ^gallery.js ../shared_files/gallery.js

Which only works as long as all the files is requested via the servers IP, i.e. http://11.11.0.111/xxx/gallery.js.

The second solution is a PHP solution:

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();
    }
}

This dosnt seem like a good solution in the long run so do anyone know of a better solution for this?

  • Edited after TerryE’s comment
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T06:04:05+00:00Added an answer on May 30, 2026 at 6:04 am

    Since your shared files reside in a location outside the VirtualHost, you should access them via an own domain/subdomain.

    So you should link http://shared.example.com/gallery.js instead (where shared.example.com is a subdomain, that links to your shared files folder).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have an Emacs-Server running on some remote server, with all the
Let's say I have a stored procedure in Microsoft SQL Server 2005 that returns
Lets say that you have websites www.xyz.com and www.abc.com. Lets say that a user
Lets say that I have a header user control in a master page, and
Lets say that you have a business object whose current state implies that there
Lets say that I have an executable and when it is started I want
Lets say that I have only DHT (distributed hash table) implemented (in Python), and
Lets say that I have the following code: public class Shelter<A extends Animal, B
To use as an example: lets say that I have 2 EditText s and
Lets just say that I have three textboxes: TextBox1, TextBox2, TextBox3. Normally if I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.