Solved

Dynamic document root based on XHTML MP browsers...

Posted on 2006-10-19
3
227 Views
Last Modified: 2010-04-20
We are currently using apache version Server version: Apache/2.0.46. We want to change the documnent root of an virtual host dynamically based on XHTML MP browsers.

Example :
example.mobi (when browsed through browser. Documentroot should be > /home/sites)
example.mobi (when browsed through XHTML MP browsers [ie: mobile] Documentroot should be > /home/sites/mobi)

we have tried using the below rewrite condition any suggestion.

RewriteCond %{HTTP_ACCEPT} application/xhtml\+xml
RewriteRule    ^(.*)$        /%1/$1 [L]

- Vijay
0
Comment
Question by:minipra
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 23

Accepted Solution

by:
rama_krishna580 earned 500 total points
ID: 17768733
Hi,

If you have plenty of sub-domains and every subdomain routes in another directory on the server, it's annoying to add every subdomain to the apache.conf (httpd.conf) file.

This can be done dynamically.

DocumentRoot /webhosts/

[...]

<VirtualHost *>
ServerAlias www.yourdomain.com
ServerName www.yourdomain.com
RewriteEngine  on
RewriteCond    %{HTTP_HOST}  ^yourdomain.com
RewriteRule    ^(.*)$        /www/$1 [L]
RewriteCond    %{HTTP_HOST}  ^www.*
RewriteRule    ^(.*)$        /www/$1 [L]
RewriteCond    %{HTTP_HOST}  ^(.*)\.yourdomain\.com
RewriteRule    ^(.*)$        /%1/$1 [L]
</VirtualHost>

As you can see, the DocumentRoot is /webhosts/. This is the directory where all other sub-directories for the sub-domains are located.

We use the RewriteEngine to decide which directory we want. The first RewriteCond is to route the domain without any sub-domain into the www directory. The second RewriteCond demonstrates how the third RewriteCond works with any subdomain.

www.yourdomain.com  =>  /webhosts/www/
muon.yourdomain.com  =>  /webhosts/muon/

Finally setup your domain as wildcard domain *.yourdomain.com in your DNS and off the fun goes!

R.K
0

Featured Post

Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question