加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

利用perl提取web配置文件中的域名对应的路径

发布时间:2020-12-16 00:44:07 所属栏目:大数据 来源:网络整理
导读:server ????????????????{ ????????????????????????????????listen????????80; ????????????????????????????????server_name www.mcshell.org mcshell.org; ????????????????????????????????index????index.php index.html index.htm; ??????????????????
server
????????????????{
????????????????????????????????listen????????80;
????????????????????????????????server_name www.mcshell.org mcshell.org;
????????????????????????????????index????index.php index.html index.htm;
????????????????????????????????root????/data0/web/mcshell;
????????????????????????????????error_page 404 =http://www.mcshell.org;
if (!-f $request_filename){
set $rule_0 1$rule_0;
}
if (!-d $request_filename){
set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){
rewrite ^/(.*)?*$ /index.php?_route_=$1 last;
}

if ($host != 'www.mcshell.org' ) {
rewrite ^/(.*)$ http://www.mcshell.org/$1 permanent;
}
..
..
现在要求提取出 www.mcshell.org? mcshell.org??? /data0/mcshell
这样的对应方式
代码如下
#!/usr/bin/perl while(<>){ chomp; if(/server_names(.*);/){ print "$1t"; $paths=<>; (undef,undef,$server )= split /s+/,$paths; #填充不需要的行 $pathss=<>; (undef,$servers )= split /s+/,$pathss; print "$serversn"; } }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读