【问题标题】:How do I modify the following squid url_rewriting_program如何修改以下鱿鱼 url_rewriting_program
【发布时间】:2014-05-21 07:41:24
【问题描述】:

请修改上述程序,以便将任何页面内的所有图像(例如 .jpg 或 .gif 图像)替换为您选择的图片。当 HTML 网页包含图像时,浏览器将识别这些图像 URL,并为每个图像发送一个 URL 请求。您应该能够在您的 URL 重写程序中看到这些 URL。您只需要确定一个 URL 是否正在尝试获取特定类型的图像文件;如果是,您可以将 URL 替换为另一个(您的选择)。

use strict;
use warnings;
# Forces a flush after every write or print on the STDOUT
select STDOUT; $| = 1;
# Get the input line by line from the standard input.
# Each line contains an URL and some other information.
while (<>)
{
my @parts = split;
my $url = $parts[0];
# If you copy and paste this code from this PDF file,
# the ˜ (tilde) character may not be copied correctly.
# Remove it, and then type the character manually.
if ($url =˜ /www\.cis\.syr\.edu/) {
    # URL Rewriting
    print "http://www.yahoo.com\n";
}
else {
    # No Rewriting.
    print "\n";
}
}

【问题讨论】:

  • 尝试编辑/usr/local/squid/etc/squid.conf
  • 这听起来像是家庭作业...

标签: linux perl firewall squid


【解决方案1】:

查看 if 块。它在 URL 上匹配,然后执行操作。你只需要做类似的事情。

查看perlrequick 页面,快速了解正则表达式在 Perl 中的工作原理。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-03
    • 1970-01-01
    相关资源
    最近更新 更多