Jump to content

Rewritemap + perl + mysql


snipe7kills

Recommended Posts

Hello all!

i know very little perl and am hoping someone here could help me make this work.

 

what i would like to do is store all the information in a mysql database so i can quickly edit and add this information without having to open a shh connection to the server.

 

i also would like to include wildcards due to the fact i have several domains and a few things should be accessible on any domain.

an example of this would be mail.* needs to go to /var/mail

 

but i would also like to be able to have *.sub0.domain.org go to /var/www/forum

or even *.domain2.org go to /var/www/crazy

while *.sub1.domain2.org goes to /var/www/crazy/dynamic_content

 

Any help would be great please feel free to contact me

sniper7kills<at>gmail.com or

AIM: sniper7kills

thank you in advance

Link to comment
Share on other sites

ok so this is what i have so far

vhosts.pl

$|=1;
use Mysql;
$db = Mysql->connect(localhost, apache, USER, PASSWORD);
$db->selectdb(apache);
$sql_query="SELECT * FROM rewritemaps";
$query = $db->query($sql_query);
while(%hash = $query->fetchhash){
	print($hash{'name'}." ".$hash{'location'});
}

 

and its being called like this:

RewriteEngine on
RewriteMap lowercase int:tolower
RewriteMap vhost prg:/etc/httpd/conf.d/vhosts.pl
RewriteCond %{REQUEST_URI} !^/icons/
RewriteCond %{REQUEST_URI} !^/cgi-bin/
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/$1
RewriteCond %{REQUEST_URI} ^/cgi-bin/
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/cgi-bin/$1 [T=application/x-httpd-cgi]

 

the mysql database is arranged like this:

Name Location
www.domain.com /var/www/html/some_folder

 

But its not working Anyone have any ideas?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.