Hi there,

I have a few sites plus a few clients' sites I have designed and manage. At present, when I want to add a new feature to all of the sites, I code it into each site individually.

What I want to achieve is to be able to update one file on one 'main' URL, and my other websites at different URLs get automatically updates as well.

At the moment I am using reseller web hosting, which shares my sites across several servers, but if I upgraded my web hosting to a dedicated server so all my websites are on just the one same server, is there a way to use a server sided technique such as PHP Include to update the other sites?

This would be the perfect solution as I am familiar with PHP and use the PHP Include everyday! If I could set up a PHP Include from another URL, it would be fantastic and make maintaining my websites a million times easier and quicker!

OR

If I built and hosted all of my sites on just one URL at sub paths e.g. maindomain.com/otherwebsite could I set up domain mapping so that another URL could be mapped to a sub path? Also, would that affect the search engine rankings as it's mapped?

Many many many thanks in advance!

Ben

Dani AI

Generated

For : centralising a shared feature so it only needs one edit is sensible — but the safe, maintainable methods are different to trying to include() code over HTTP. A remote include('http://...') either pulls the remote script’s output (not its PHP source) or requires server settings that are insecure and usually disabled. Relying on that pattern invites syntax errors, security holes, and hosting restrictions.

A few recommended approaches (tradeoffs noted):

  • Put the common PHP library on the same server and reference it by filesystem path (shared dir outside webroots or a symlink into each site). This is simple and fast; permissions and include_path need attention.
  • Use version control: store shared code in its own Git repo and deploy it to each site (git submodule/subtree, or better — a private Composer package). This gives versioning, rollbacks and controlled updates.
  • Mount a central fileshare (NFS/SSHFS) if many servers must access the same files in real time — useful at scale but introduces a single point of failure and operational complexity.
  • Turn shared functionality into a service (API) for cross-site reuse — good for logic/JSON widgets, not for including PHP templates.

Domain-to-subpath mapping is perfectly doable: point the domain’s DNS to the server and configure the virtual host to set DocumentRoot to the subfolder (cPanel “addon domain” does the same). Example Apache vhost and a minimal nginx server block show the idea:

<VirtualHost *:80>
  ServerName otherdomain.com
  DocumentRoot /var/www/maindomain/otherwebsite
</VirtualHost>
server {
  listen 80;
  server_name otherdomain.com;
  root /var/www/maindomain/otherwebsite;
}

SEO and ops notes: duplicate content across domains can hurt rankings — use a single canonical domain (301 redirects or rel="canonical") if content is identical. Centralising code creates a single point of failure; use automated deploys (CI/CD) or versioned releases to roll changes safely. Common troubleshooting points: file permissions, open_basedir/include_path limits, SELinux, and disabled allow_url_include — check logs and enable error reporting when debugging.

Agreeing with ’s folder-mapping idea, the safer long-term choice is shared filesystem or a deployment-based workflow rather than remote PHP includes.

I have the second situation. On my personal (reseller) domain i have a sub-folder called 'hosted' where each different website has a sub-folder. The domain name for that website is mapped to that folder. SE's really don't notice this. For PHP it makes no difference to what domain the folder is mapped, since it is all the same server. You can use absolute paths in your includes to locate files in a specific folder that has files which are the same for every website (e.g. '/my_common_folder/mysql.class.php').

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.