Read virtual domain name from httpd conf file

From Bioperl.info

Jump to: navigation, search


#------------------------------------------------------------------------
# Title     :
# Usage     :
# Function  :
# Example   :
# Keywords  :
# Options   :
# Author    : j@bio.cc
# Category  :
# Reference :
# Returns   : lowercase domain name (without the dot and TLD name): e.g. "biosophy"
# Version   : 20070525
#-------------------------------------------------------------------------
sub read_virtual_domain_name_from_httpd_conf_file{
    my($httpd_conf_input, %dom_name_hash, $virtual_host_flag);
    if(-s $_[0]){
       $httpd_conf_input=$_[0];
    }else{
       $httpd_conf_input="/etc/httpd/conf/httpd.conf";
    }
    open(FILE2, "<$httpd_conf_input") || die "\n Can not open $httpd_conf_input\n";
    while(<FILE2>){
        $virtual_host_flag=0;
        if(/\<VirtualHost\s+\*\:80\>/){
            $virtual_host_flag=1;

            next;
        }elsif(/ServerName\s+(\S+)\.(\w+)/){
            $dom_name_hash{"\L$1"}="\L$1";
            $virtual_host_flag=0;
            next;
        }
    }
    return(\%dom_name_hash);
}

 




Personal tools