Link to home
Start Free TrialLog in
Avatar of dlamar
dlamar

asked on

mod_rewrite problem - redirect all requests for domain name to subfolder

Hi, I have a domain name (mydomain1.com) that contains all the base code for a large number of individual sites. The individual sites reside in a directory structure within mydomain1.com - /clientsites/clientdomain.org - I would like to configure it so that when a request is made for a page at: clientdomain.org - the page is served from mydomain.com/clientsites/clientdomain.org/ - without changing the URL (at least the clientdomain1.org part) in the address bar.

I have been reading lots of articles on the web, but can't find one that addresses this specifically and am a bit lost on the proper rewrite rules to apply.
Avatar of Julian Matz
Julian Matz
Flag of Ireland image

Hi! This can be relatively easy or fairly difficult. A rewrite won't work since you are using separate domains.

The easy way would be to add the clientdomains.org to the same server/account as mydomain1.com and specify mydomain.com/clientsites/clientdomain.org/ as the root directory.

For example, in cPanel, you can add an "Add-on Domain" that has a different root directory as the account's primary domain.

Another option might be to use mod_proxy to set up a reverse proxy.

Do you think the first option might work for you? The one problem with this will be that you cannot access static content like images, CSS and JavaScript files from your primary domain's root directory. You will however be able to access PHP scripts.
Avatar of dlamar
dlamar

ASKER

Thanks for the reply. I am aware that the first option works.... and in fact have had a similar system set up that way for a couple of years. What I'm trying to accomplish is to keep a default set of files (templates, images, php code etc.) in the mydomain1.com directory area that the sites in the clientsites subdirectory can access. Then I'll only put files in the clientsites directory that need to override the default files. That way when I need to make functionality changes to the core set of files I only have to do it once - and I don't have to go into each of the 200+ clientsites and make the update. Esssentially, I'm running a home-grown CMS with drop-in modules.

I'm not familiar with the reverse proxy. I'll do some research on mod_proxy. If you can give me some more specific direction on that I'd appreciate it.
No problem. I haven't used mod_proxy much personally, but did do some research on it some time back. I'll see if I can gather up the infos I have and send them later today.
ASKER CERTIFIED SOLUTION
Avatar of Julian Matz
Julian Matz
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Use the Addon Domain feature and give the path as clientsites/clientdomain.org