[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Dynamic document root based on XHTML MP browsers...

Posted on 2006-10-19
3
Medium Priority
?
230 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 2000 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

649 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