Forum Moderators: coopster & phranque

Message Too Old, No Replies

RewriteMap Perl and Mysql Script run Once

         

asqpk

4:50 am on Jul 8, 2008 (gmt 0)

10+ Year Member



Hi there
I am observing a malfunction while i am applying RewriteMap Perl and MySql solution

my httpd.conf script is :
RewriteEngine on
RewriteLogLevel 3
RewriteLog "/rewrite.log"
RewriteMap chmap prg:/check.pl
RewriteRule /sites.examples/(.*) ${chmap:$1} [NS,P]

and my perl file script is:

#!/usr/bin/perl

$¦=1;

# PERL MODULES
use Mysql;

# MYSQL CONFIG VARIABLES
$host = "localhost";
$database = "test";
$tablename = "rewrite";
$user = "#*$!xx";
$pw = "#*$!#*$!x";

# PERL CONNECT()
$connect = Mysql->connect($host, $database, $user, $pw);

# SELECT DB
$connect->selectdb($database);

#print 'http://192.168.1.24/website/sites/0162/examples@examples.com/s_31324654646464/index.html';

while (my $in = <STDIN>){

# $_ -- This holds the requested url to rewrite
chomp($in);

my $myquery = 0;
my $execute = 0;
my $array = 0;

# DEFINE A MySQL QUERY
$myquery = "SELECT * FROM rewrite WHERE short = \"$in\"";

# EXECUTE THE QUERY FUNCTION
$execute = $connect->query($myquery);
@array = $execute->fetchrow;
print 'http://192.168.1.24/'.$array[1];

}
##EOF##

when i try to hit URL
[192.168.1.24...]

it never returns anything and keep trying to load

in log file i found this
192.168.1.10 - - [25/Jun/2008:22:08:12 +0500] [192.168.1.24/sid#877f398][rid#8b2bfc0/initial] (2) init rewrite engine with requested uri /sites.examples/helloworld
192.168.1.10 - - [25/Jun/2008:22:08:12 +0500] [192.168.1.24/sid#877f398][rid#8b2bfc0/initial] (3) applying pattern '/sites.examples/(.*)' to uri '/sites.examples/helloworld'

browser keep trying to load but nothing came up

on the other hand when i run this perl script on shell it runs well takes input and print the path and then listen for another input

could anyone please help me in this regard

Thanks

perl_diver

8:20 pm on Jul 9, 2008 (gmt 0)

10+ Year Member



You need to print an http header before printing anything else to the browser:

print "Content-type: text/html\n\n";

the double-quotes and two \n\n are important. Add that and see if it helps.

Besides that I have no other suggestion. The server directives you are using are not familiar to me.