Forum Moderators: phranque

Message Too Old, No Replies

rewritemap map-type

mysql

         

AcMe

8:05 pm on Dec 26, 2005 (gmt 0)

10+ Year Member



How can I save my virtual hosts map entries into mysql database?
I need to make an web interface for users, that they will add, delete, modify their subdomains.
Is maybe another way to make this with any mysql database?

jdMorgan

11:40 pm on Dec 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



AcMe,

Welcome to WebmasterWorld!

This is not a simple subject, and we'll need a lot more information to determine what you have in place now, what you'd like to do, and how you'd like to do it.

More-detailed questions are likely to get more-detailed answers.

Jim

AcMe

10:25 am on Dec 28, 2005 (gmt 0)

10+ Year Member



My situation now (Apache/2.0.54):

/etc/apache2/httpd.conf:

RewriteEngine on
Options Indexes FollowSymlinks Multiviews

RewriteMap lowercase int:tolower
RewriteMap vhost txt:/etc/apache2/vhost.map
RewriteCond %{REQUEST_URI} !^/icons/
RewriteCond %{REQUEST_URI} !^/cgi-bin/
RewriteCond %{HTTP_HOST} !^$
RewriteCond ${lowercase:%{HTTP_HOST}¦NONE} ^(.+)$
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/$1 [E=VHOST:${lowercase:%{HTTP_HOST}}]

RewriteCond %{REQUEST_URI} ^/cgi-bin/
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/cgi-bin/$1

/etc/apache2/vhost.map:

www.domain1.com /home/user1/public_html/www.domain1.com
mail.domain1.com /home/user1/public_html/mail.domain1.com
www.domain2.net /home/user2/public_html/www.domain2.net
subdomain.domain3.org /home/user3/public_html/subdomain.domain3.org

So, I make changes in my vhost.map file "with hands" as root now. I need to make an web interface for users, that they will add for example "subdomain2.domain3.org /home/user3/public_html/subdomain2.domain3.org" in vhost.map file.
What is the easiest and secure way? I think, that I can do this with PHP (fopen vhost.map) or store all vhost map information in database, but apache can`t connect to mysql.
What is your offer?

jdMorgan

4:02 pm on Dec 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See the Apache RewriteMap documentation. You can use RewriteMap to call any cgi script and return the results to the URL-processing stream. So, your config file can call cgi scripts, which can then access your database to return 'subdomain defined' status, and subdomain-to-subdirectory mapping information.

This is a complex subject, with most of the work outside the scope of pure Apache-server. Therefore, I can only generalize an approach.

Jim

AcMe

4:09 pm on Dec 28, 2005 (gmt 0)

10+ Year Member



Thanks, I have now course :)