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
https://forums.phpfreaks.com/topic/96928-rewritemap-perl-mysql/
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
https://forums.phpfreaks.com/topic/96928-rewritemap-perl-mysql/#findComment-498527
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.