LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Subdomain inherit and override (https://www.linuxquestions.org/questions/linux-server-73/subdomain-inherit-and-override-656008/)

theodm 07-15-2008 06:34 PM

Subdomain inherit and override
 
I'm wondering if the following is possible. I have a pretty big website with quite some php files (Debian server with Apache2 and PHP5). Now some subdomains have to be created that are basically a copy of the main website, but some changes here and there like extra features specific for that subdomain etc.

With a few subdomains it's fine, but if it's 50 of them, all being copies, having to make a change that goes for all is not really practical.

Due to every subdomain having specific things it doesn't seem to be that easy to set things up in a way that prevents me from having copies. The ideal thing would be if something could be done that basically checks the subdomain path for a requested file and if it's not there fallback to the main website for the file, altough of course that file may include other php files, use images etc. With htaccess rewrites I could get something done probably, but that still wouldn't be able to catch it all probably.

I guess I'm not the only one with this problem, but haven't really been able to find anything so far. Any ideas or suggestions?

Mr. C. 07-16-2008 02:20 PM

How about a standard default directory with all the pages, and then each subdomain is a series of symlinks to the originals in the standard default directory.

When you create a new site, you just mirror the tree with symlinks. When you need to customize, you remove a symlink and replace it with a modified copy of the target.

theodm 07-17-2008 02:35 AM

Yes I considered doing it like that, but I think the site has about thousand files all over and it's being worked on by some Indians who probably never even heard of a symbolic link, so I wonder how long it would take for them to break something :)

It's too bad Apache doesn't have some kind of fallback dir or something, that you can tell it here's the site root, but if you can't find a file check there as well. You would still have to do some extra checking when doing php includes then but that's doable.

I'll do some testing with the symlink option. If I'm lucky the ftp will just overwrite the symlink when a file is uploaded with the same name instead of overwriting its target.

Thanks for sharing your thoughts!

Mr. C. 07-17-2008 10:59 AM

Well, there are hierarchies:
Code:

  1- master config
      2-.htaccess
      2- virtual hosts
        3- .htaccess

And this doesn't include Directory constructs, which are orthogonal.

You can probably accomplish some of this at the mod_rewrite level, where you dynamically determine the file to serve based upon its existence in one tree or another.

While I don't think its fair to label an entire people as incompetent, I understand that you have concerns about the competence of your particular team members. Those who can't manage a symbolic link would tremble at the site of an apache configuration manual.

Best of luck.

theodm 07-18-2008 07:05 AM

I didn't mean that all Indians are like that, I was talking about this particular team :)

Unfortunately with ftp it just overwrites the target, so when using symbolic links it's probably just a matter of time before a mistake is made.

The few mod_rewrite things I tried haven't been successful so far, but I'll see how far I get.

Mr. C. 07-18-2008 11:31 AM

I figured you were a nice person; I meant no harm.

Sounds like a challenging situation.

mod_rewrite is not my favorite either. Mr. Engelschall is brilliant, yet writing approachable scripting languages is not best suit. But mod_rewrite is so powerful, it is worth obtaining additional learning material to help you through your situation.


All times are GMT -5. The time now is 08:33 PM.