mod_rewrite problem - redirect all requests for domain name to subfolder

Hi, I have a domain name ( that contains all the base code for a large number of individual sites. The individual sites reside in a directory structure within - /clientsites/ - I would like to configure it so that when a request is made for a page at: - the page is served from - without changing the URL (at least the 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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian MatzTechnical SupportCommented:
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 to the same server/account as and specify 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.
dlamarAuthor Commented:
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 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.
Julian MatzTechnical SupportCommented:
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.
Julian MatzTechnical SupportCommented:
OK, I've done some testing myself, and I think the easiest way for you to run a proxy is to use a rewrite rule. One of the advantages is that you can use these inside a .htaccess file.

It might be a good idea to start off with a simple enough test, to make sure mod_proxy is loaded etc.

So, add the following to a .htaccess file located in your www root:

RewriteEngine On
RewriteRule ^test357$ [P]

The [P] flag indicates that you want to proxy the request.

Upload that and then point your browser to

Remember NOT to add a trailing slash after "test357". You should now be served Google Search's index page.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Use the Addon Domain feature and give the path as clientsites/
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.