- Code: Select all
Options +FollowSymLinks
RewriteEngine On
RewriteMap vhost prg:/etc/httpd/conf/rewrite.pl
RewriteRule .* ${vhost:%{HTTP_HOST}|/var/www/html/docs}%{REQUEST_URI} [PT,L]
with and without the print statement.
Options +FollowSymLinks
RewriteEngine On
RewriteMap vhost prg:/etc/httpd/conf/rewrite.pl
RewriteRule .* ${vhost:%{HTTP_HOST}|/var/www/html/docs}%{REQUEST_URI} [PT,L]
192.168.1.43 - - [12/Apr/2008:21:00:43 --0400] [www.sniper7kills.org/sid#9f78e78][rid#a282f60/initial] (2) init rewrite engine with requested uri /
192.168.1.43 - - [12/Apr/2008:21:00:43 --0400] [www.sniper7kills.org/sid#9f78e78][rid#a282f60/initial] (3) applying pattern '.*' to uri '/'
192.168.1.43 - - [12/Apr/2008:21:00:43 --0400] [www.sniper7kills.org/sid#9f78e78][rid#a282f60/initial] (5) map lookup OK: map=vhost key=www.sniper7kills.org -> val=www.sniper7kills.org
192.168.1.43 - - [12/Apr/2008:21:00:43 --0400] [www.sniper7kills.org/sid#9f78e78][rid#a282f60/initial] (2) rewrite / -> www.sniper7kills.org/
192.168.1.43 - - [12/Apr/2008:21:00:43 --0400] [www.sniper7kills.org/sid#9f78e78][rid#a282f60/initial] (2) forcing 'www.sniper7kills.org/' to get passed through to next API URI-to-filename handler
192.168.1.43 - - [12/Apr/2008:21:00:45 --0400] [www.sniper7kills.org/sid#9f78e78][rid#a282f60/initial] (2) init rewrite engine with requested uri /
192.168.1.43 - - [12/Apr/2008:21:00:45 --0400] [www.sniper7kills.org/sid#9f78e78][rid#a282f60/initial] (3) applying pattern '.*' to uri '/'
192.168.1.43 - - [12/Apr/2008:21:00:45 --0400] [www.sniper7kills.org/sid#9f78e78][rid#a282f60/initial] (5) map lookup OK: map=vhost key=www.sniper7kills.org -> val=/var/www/html/sniper7kills.orgwww.sniper7kills.org
192.168.1.43 - - [12/Apr/2008:21:00:45 --0400] [www.sniper7kills.org/sid#9f78e78][rid#a282f60/initial] (2) rewrite / -> /var/www/html/sniper7kills.orgwww.sniper7kills.org/
192.168.1.43 - - [12/Apr/2008:21:00:45 --0400] [www.sniper7kills.org/sid#9f78e78][rid#a282f60/initial] (2) forcing '/var/www/html/sniper7kills.orgwww.sniper7kills.org/' to get passed through to next API URI-to-filename handler
192.168.1.43 - - [12/Apr/2008:21:00:52 --0400] [mail.sniper7kills.org/sid#9f78e78][rid#a282f60/initial] (2) init rewrite engine with requested uri /
192.168.1.43 - - [12/Apr/2008:21:00:52 --0400] [mail.sniper7kills.org/sid#9f78e78][rid#a282f60/initial] (3) applying pattern '.*' to uri '/'
192.168.1.43 - - [12/Apr/2008:21:00:52 --0400] [mail.sniper7kills.org/sid#9f78e78][rid#a282f60/initial] (5) map lookup OK: map=vhost key=mail.sniper7kills.org -> val=/var/www/html/sniper7kills.orgmail.sniper7kills.org
192.168.1.43 - - [12/Apr/2008:21:00:52 --0400] [mail.sniper7kills.org/sid#9f78e78][rid#a282f60/initial] (2) rewrite / -> /var/www/html/sniper7kills.orgmail.sniper7kills.org/
192.168.1.43 - - [12/Apr/2008:21:00:52 --0400] [mail.sniper7kills.org/sid#9f78e78][rid#a282f60/initial] (2) forcing '/var/www/html/sniper7kills.orgmail.sniper7kills.org/' to get passed through to next API URI-to-filename handler
192.168.1.43 - - [12/Apr/2008:21:00:56 --0400] [mail.sniper7kills.org/sid#9f78e78][rid#a282f60/initial] (2) init rewrite engine with requested uri /
192.168.1.43 - - [12/Apr/2008:21:00:56 --0400] [mail.sniper7kills.org/sid#9f78e78][rid#a282f60/initial] (3) applying pattern '.*' to uri '/'
192.168.1.43 - - [12/Apr/2008:21:00:56 --0400] [mail.sniper7kills.org/sid#9f78e78][rid#a282f60/initial] (5) map lookup OK: map=vhost key=mail.sniper7kills.org -> val=/var/www/html/mailmail.sniper7kills.org
192.168.1.43 - - [12/Apr/2008:21:00:56 --0400] [mail.sniper7kills.org/sid#9f78e78][rid#a282f60/initial] (2) rewrite / -> /var/www/html/mailmail.sniper7kills.org/
192.168.1.43 - - [12/Apr/2008:21:00:56 --0400] [mail.sniper7kills.org/sid#9f78e78][rid#a282f60/initial] (2) forcing '/var/www/html/mailmail.sniper7kills.org/' to get passed through to next API URI-to-filename handler
#!/usr/bin/perl
#
# IT Integrated Business Solutions (c) 2008
# http://www.it-iss.com
#
# Author: Ronan Cashell
# There is no warranty that goes with this script.
#
# For this to work we must connect to the database and await STDIN. The input is then cross checked against
# the database for a valid entry. An example:
#
# If entry provided is mail.domain.com we need to rewrite to /var/www/html/mail
# In a one to one match this is easy. However, wildcards are also supposed to work
# with this utility. So if mail.domain.com is entered then we need to cross check against
# the database to see the first match in the database against this.
#
# So lets imagine in the database we have *.domain.com this means that anything requesting
# www.domain.com/mail.domain.com ... should have the rewrite. A sort order is included to
# configure the first match that it picks up.
#
# the MySQL instr function will help check if the entry exists in the database
use strict;
use DBI;
$| = 1;
my $dbh = DBI->connect( 'dbi:mysql:rewrite:localhost',
'USER',
'PASSWORD') || die "Database connection not made: $DBI::errstr";
my $in;
while ($in = <STDIN>) {
#$in = 'mail.domain.com';
#print "" . $in;
#print $in;
my $sql = "SELECT name, rewrite FROM rewrite WHERE INSTR('" . $in . "', name) > 0 ORDER BY sort_order ASC";
my $sth = $dbh->prepare( $sql );
$sth->execute();
my( $name, $rewrite);
$sth->bind_columns( undef, \$name, \$rewrite );
if($sth->fetch()) {
print $rewrite."\n";
} else {
# Important to have a default if there are no matches. Otherwise Apache will hang.
print "/var/www/html\n";
}
$sth->finish();
print $_;
}
$dbh->disconnect();
options +Indexes +FollowSymlinks
RewriteEngine On
RewriteMap vhost prg:/etc/httpd/conf/rewrite.pl
rewriteCond %{REQUEST_URI} !^/icons/
rewriteCond %{REQUEST_URI} !^/cgi-bin/
RewriteRule ^(.*)$ ${vhost:%{HTTP_HOST}}$1 [PT,L,NS]
options +ALL
RewriteEngine On
RewriteMap vhost prg:/etc/httpd/conf/rewrite.pl
# deal with aliases as above
RewriteCond %{REQUEST_URI} !^/icons/
RewriteCond %{REQUEST_URI} !^/cgi-bin/
RewriteCond ${%{HTTP_HOST}} ^(.+)$
# this does the file-based remap
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/$1
RewriteCond %{REQUEST_URI} ^/cgi-bin/
RewriteCond ${{HTTP_HOST}} ^(.+)$
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/cgi-bin/$1
# Creates a blank database
CREATE DATABASE rewrite;
# Creates the user with the permissions
GRANT all on rewrite.* to locahost@rewrite identified by ‘rewrite’;
# Create the table
CREATE TABLE rewrite (
name varchar(100),
rewrite varchar(100),
sort_order int
);
Options All
RewriteEngine On
RewriteMap vhost prg:/etc/httpd/conf/rewrite.pl
RewriteRule !^/(icons|cgi-bin)(/.*)?$ ${vhost:%{HTTP_HOST}}%{REQUEST_URI} [NC,PT,L]
RewriteRule ^(/cgi-bin(/.*)?)$ ${vhost:%{HTTP_HOST}}$1 [NC,PT,L]
Users browsing this forum: No registered users and 4 guests