List The VirtualHosts on Apache Server

Here is a small scripts that allows an individual or an organisation to get a clean list of all the virtual host that are currently running on a Apache Server:

<h1>Virtual Host on this server</h1>
$arr = array();
exec('apachectl -S |grep namevhost',$arr);
foreach($arr as $key=>$value){
$value= substr($value,strpos($value,'namevhost ')+10);
$value = substr($value,0,strpos($value,' '));
echo '<li><a href="http://'.$value.'">'.$value.'</a></li>';

Leave a Reply

Your email address will not be published. Required fields are marked *