I have 3 domains and I want to write one administration panel. 90% of code is common for all websites.
Is it good idea to use one index.php and $_SERVER[HTTP_HOST]
to find out which site to show? Or maybe use four folders in root (one for each website) and keep common files out of these folders.
Eg.
ROOT
WWW1
/index.php
WWW2
/index.php
WWW3
/index.php
ADMIN
/index.php
/config.cfg
/.htaccess
IMG
MEDIA
IMG
DOCS
MUSIC
VIDEO
SRC
JS
CSS
Or maybe there is other solution.
This is a decision that there is no "right answer" for - it's a decision that needs to be made on a per-site basis. As you've already identified, if most of the code is common across all the sites, sharing them does make a lot of sense.
You might also want to think about what kind of admin tasks you're expecting: are these sites going to have the same admin or is there a different set for each site? Will these administrators have similar needs / abilities? If they are, again a shared admin makes a lot of sense.
In terms of one index vs an index for each site: how much config / setup do your sites require? If all sites run almost the same way, one index page might make sense, and then the 10% of code that's different can be handled on an adhoc basis. Again, if the bootstrap / setup needs to be very different for each site, a separate index for each site makes sense, so they can set up their own environments before calling the 90% similar code.
So, in conclusion, I'm not going to say "yes" or "no" to anything because I don't know enough about your setup to give a solid answer. However, I have worked on sites that follow schemes like this successfully, and you seem to be following a sensible logic, so this solution certainly doesn't have any glaring issues.
Hope this helps :) x