Read virtual domain name from httpd conf file

From Bioperl

Jump to: navigation, search


  1. ------------------------------------------------------------------------
  2. Title     :
  3. Usage     :
  4. Function  :
  5. Example   :
  6. Keywords  :
  7. Options   :
  8. Author    : j@bio.cc
  9. Category  :
  10. Reference :
  11. Returns   : lowercase domain name (without the dot and TLD name): e.g. "biosophy"
  12. Version   : 20070525
  13. -------------------------------------------------------------------------

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
Documentation
Google AdSense