parser

Написать ответ на текущее сообщение

 

 
   команды управления поиском

враппер на перле - работает харошо

Janek 25.01.2010 14:35 / 25.01.2010 14:37

.htaccess
RewriteEngine on
RewriteOptions maxredirects=5

RewriteRule (.*)\.html$ parser3.pl
RewriteRule (.*)/$ parser3.pl
RewriteRule ^$ parser3.pl
parser3.pl
$parserDir = "/hidden/bin/parser3/";
$filename = $ENV{'SCRIPT_URL'};

#some rewrite rules (from apache's .htaccess)
#RewriteRule ^(.*/)n\.([0-9]*)/$ $1/?mod_news.id=$2 [L,QSA]
@matches = ($filename =~ m|(.*/)n\.([0-9]*)/$|);
if(scalar(@matches) == 2){
	$filename = @matches[0];
	$ENV{'QUERY_STRING'} = "mod_news.id=".@matches[1];
}


if(substr($filename,length($filename)-1) eq "/"){
	$filename = $filename."index.html";
}

$ENV{'PATH_INFO'} = $filename;
$ENV{'PATH_TRANSLATED'} = "/".$ENV{'PATH_INFO'};
$ENV{'SCRIPT_NAME'} = $parserDir.'parser3.cgi';
$ENV{'CGI_PARSER_CONFIG '} = $parserDir.'auto.p';
$ENV{'SCRIPT_FILENAME'} = $ENV{'SCRIPT_NAME'};

delete $ENV{'PATH_REDIRECTED'};
$ENV{'REDIRECT_URL'} = $ENV{'PATH_INFO'};

if(-e $ENV{'PATH_TRANSLATED'}){
	system($ENV{'SCRIPT_NAME'});
}else{
	print("HTTP/1.1 404 Not Found\n");
	print("Server: Parser3 Wrapper\n");
	print("Content-Type: text/html\n");
	print("Connection: Keep-Alive\n\n");
	print("<html><head><title>404 Not Found</title></head>");
	print("<body><h1>404 Not Found</h1><p>The request was not found on this server.</p>");

#	display env for debugging
#	print('<pre style="border: 1px solid #000; padding: 10px; background-color: #eee">');system("env");print("</pre>");

	print("</body></html>");
}
Большое спасибо для Moko и Sumo за советы и поддержку!