Re: hellp improve efficiency



Perhaps I'm misunderstanding what you're ultimately trying to
accomplish. However, if you're doing what I think you're doing and
you're using Apache, look into mod_rewrite:
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

- sf

Jen mlists wrote:
Hello members,

I wrote a perl script for url redirect,shown as below,

$|=1;
my $uri = '';

while (<>) {

$uri = (split)[0];

if ($uri =~ /\.html?\?/ or $uri =~ /\.js\?/ or $uri =~ /\.css\?/ or
$uri =~ /\.jpg\?/ or $uri =~ /\.gif\?/ or $uri =~ /\.swf\?/) {
$uri =~ s/\?.*$//;
}

if ($uri =~ m|www\.example\.com/v/|o) {
$uri =~ s|www\.example\.com/v/|v.example.com/|;

}elsif ($uri =~ m|www\.example\.com/v2/|o) {
$uri =~ s|www\.example\.com/v2/|v2.example.com/|;

}elsif ($uri =~ m|www\.example\.com/v3/|o) {
$uri =~ s|www\.example\.com/v3/|v3.example.com/|;

}elsif ($uri =~ m|www\.example\.com/so/|o) {
$uri =~ s|www\.example\.com/so/|so.example.com/|;

}elsif ($uri =~ m|www\.example\.com/admin/\?.*|o) {
$uri =~ s|www\.example\.com/admin/\?.*|www.example.com/admin/|;

}elsif ($uri =~ m|www\.example\.com/w\?v=|o) {
$uri =~ s|www\.example\.com/w\?v=|v2.example.com/v_|;

}elsif ($uri =~ m|www\.example\.com/([wulp])(\d+)/|o) {
$uri =~ s|www\.example\.com/([wulp])(\d+)/|$2.$1.example.com/|;

}elsif ($uri =~ m|www\.example\.com/([wulp])/|o) {
$uri =~ s|www\.example\.com/([wulp])/|$1.example.com/|;
}

} continue {

print "$uri\n";

}

__END__

As you see,for each regex match,I've tested it twice.
Maybe it's going with low-efficiency.How can improve it?Thanks.

.



Relevant Pages

  • Re: Please help, directory level protection needed.
    ... Going back to my original post, I thought my statement about what I was ... trying to accomplish, how I had accomplished it in the past, and why I ... Please feel free to go back to my original post, and the replies of ... I don't want to debate which is better Apache or IIS, ...
    (microsoft.public.inetserver.iis.security)
  • RE: Directory listing
    ... if you can inject the following script to an apache server running php, you will be able to execute any command ... accomplish on other types of web server like Apache? ... Can this be accomplished with a cgi or perl script? ... Did you know that you have VNC running on your network? ...
    (Pen-Test)
  • Re: Documents link on Start Menu
    ... I just did a right-click | Delete to accomplish that. ... misunderstanding something? ... > In TweakUI under the explorer options is the one you want ...
    (microsoft.public.windowsxp.basics)
  • Re: hellp improve efficiency
    ... accomplish. ... you're using Apache, look into mod_rewrite: ... redirector for Squid cache. ...
    (perl.beginners)
  • Time Calculations
    ... Matt, perhaps I'm misunderstanding what your attempting to do, but it ... Is there a better way to accomplish this, ... any forseen problems with my approach? ...
    (microsoft.public.excel.worksheet.functions)