logo
Apache Lounge
Webmasters

 


About

Forum Index Downloads Search Register Log in  RSS Apache Lounge
 



Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Apache Lounge is not sponsored.

Your donations will help to keep this site alive and well, and continuing building binaries.



Example Using a database (DBD) for vhost, mod_vhost_dbd.so

 
Post new topic   Reply to topic    Apache Forum Index -> How-to's & Documentation & Tips



View previous topic :: View next topic  
Author Message
admin
Site Admin


Joined: 15 Oct 2005
Posts: 549

PostPosted: Sat 16 Feb '08 16:52    Post subject: Example Using a database (DBD) for vhost, mod_vhost_dbd.so Reply with quote

Received from Tom the following on the use of DBD Virtual Host module - mod_vhost_dbd.so ,
see http://www.apachelounge.com/viewtopic.php?t=2235

Using this database table (hostTable) to send requests to different web roots based on the hostname.
This is like using NameVirtualHost / <VirtualHost>, but the DocumentRoot is looked up in the
database instead of being set inside many <VirtualHost> directives. Records can be added or removed
from the table without needing to restart Apache.
Code:
hostname         root
--------------   ------------
www.acme.com     D:/acme/web
www.gadget.com   F:/www/gadgetco
www.main.com     E:/htdocs

The directive would be:

DBDocRoot "SELECT root FROM hostTable WHERE hostname = ?", HOSTNAME

-------------------------------------
Using a part of a URI is less common, but there are cases where it is useful.
Using this database table (typeTable) to send different requests to different web roots based on the
first 1 part of the URI:
Code:
type          root
-----------   ------------
/webmail      C:/maildir
/download     E:/other
/temp         D:/

The directive would be:

DBDocRoot "SELECT root FROM typeTable WHERE type = ?", URI1

In this example, a request to http://{server}/webmail/steffen/test/alpha/index.html
would go to C:\maildir\webmail\steffen\test\alpha\index.html
because C:\maildir is the document root.

A request to http://{server}/download/beta/bigfile.pdf
would go to E:\other\download\beta\bigfile.pdf
because E:\other is the document root.

Requests which don't begin with /webmail, /download, or /temp would still go to the regular location
set by the DocumentRoot directive in httpd.conf.

Steffen
Back to top


Post new topic   Reply to topic    Apache Forum Index -> How-to's & Documentation & Tips
Page 1 of 1