Php – Sharing includes files with PHP across domains on shared hosting

configurationPHPshareshared-hosting

  1. Can I use an includes folder on one website and set up "trusted domains/IPs" that are allowed to access the files in this folder (all other domains/IPs are restricted)? All the sites are on the same shared hosting server, the global site has a dedicated IP, the others share a different IP.

  2. Is this too insecure to allow PHP includes across domains?

  3. If this scenario is not possible to configure, are there some alternatives to share server-side files globally and relatively securely?

Edit: Server is Apache

When including files across domains it gives the error:

Warning: include(/home/user1/public_html/file.php) [function.include]:
failed to open stream: Permission denied in /home/user2/public_html/file.php

Best Answer

If all the websites are on a shared server you can make a folder readable and they can include that way. Say /blah/globalphpshare/ and user 'homer' wants to use greet.php he/she could simply do include("/blah/globalphpshare/greet.php");

Related Topic