Mobile app version of vmapp.org
Login or Join
Chiappetta492

: Configure files to come from a central location unless that file has been customized for a specific site I have an user A on a server, this users has a working set of scripts (html+js+css+everything

@Chiappetta492

Posted in: #Apache #Files #Vhost

I have an user A on a server, this users has a working set of scripts (html+js+css+everything else).
I also have users B-[as much as I want]. I want those to use the exact same files, but if they have the file themselves, use that. Like a multi-user file_exists() on server level.

Say the user B has /templates/index.html, I want the site to use all over User A's files, apart from that template (which is User B's). Much like an alias, until a file exists.

Could anyone point my in the right direction, I'm able to work on server level, I simply don't know the terms, I don't know what I'm looking for.



Example:

USER A USER B USER C
.htaccess
index.php
/templates/ /templates/ /templates/
- index.html
- header.html - header.html
- footer.html - footer.html


USER B uses all of USER A's files, apart from header.html
USER C uses all of USER A's files, apart from footer.html

An easy way to explain: User's B&C are an alias of A, apart from the few existing files. Pretty urls have to remain working.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Chiappetta492

1 Comments

Sorted by latest first Latest Oldest Best

 

@Cugini213

If you're using Apache webserver you might use:

# Turn on redirection module in case not already on
RewriteEngine On
# If requested file doesn't exist
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
# and the requested file is /scripts/script.php
RewriteCond %{REQUEST_FILENAME} ="/scripts/script.php"
# then use the script made available to all users
RewriteRule ^.*$ /scripts-global/script.php [L]


Though it is probably worth mentioning that from Apache v2.2 the -f test (to see if a file exists) does not work with relative paths so if looking to replace %{DOCUMENT_ROOT} then you'll need to replace it with a full path such as /home/users/martijn.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme