本文介绍了如何显示"虚拟主机"名单WAMP 2.5主页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有大量的指令是什么设置,改为显示在WAMP主页上的虚拟主机列表中,但是在用C检查的index.php:// WAMP / WWW有似乎没有code在这里显示虚拟主机无论什么设置在其他地方。所以,我增加了一些code对自己表现出这份名单,并认为这可能会帮助其他人谁希望这样做。

这需要你的httpd-vhosts.conf文件有条目,如以下

 <虚拟主机*:80>
     的DocumentRootC:/ WAMP / WWW / website_folder_name
     服务器名WEBSITE_NAME#< ----------这是什么用途的index.php
     <目录C:/ WAMP / WWW / website_folder_name>
          所有的AllowOverride
          要求地方
     < /目录>
< /虚拟主机>

现在,在C://wamp/www/index.php进行以下更改:

这行之后(65行)$ wampserverVersion = str_replace函数('','',$结果[1]);

地址:

  $ wampVHostsFile = $ server_dir.'bin /阿帕奇/ apache2.4.9 / conf目录/额外/的httpd-vhosts.conf';
如果(!is_file($ wampVHostsFile))
     模具(无法打开虚拟主机的文件,请更改路径index.php文件');
$计划生育=的fopen($ wampVHostsFile,'R');
$ wampVHostsFileContents = FREAD($ FP,文件大小($ wampVHostsFile));
FCLOSE($ FP);$虚拟主机=;
$结果=阵列(1 =>阵列(1 => 786));
而(!空($结果)){
     preg_match('|服务器名称(*)|',$ wampVHostsFileContents,$结果,preG_OFFSET_CAPTURE,$结果[1] [1]);
     array_key_exists(1,$结果)? 。$虚拟主机='<李>< A HREF ='($ SUP press_localhost的http://:?)$结果[1] [0]。'>' 。$结果[1] [0]。'< / A>< /李>' : 空值;
}如果(空($虚拟主机))
     $虚拟主机=<立GT;没有虚拟主机< /李> \\ N;;

然后滚动到文件的底部,并编辑$包含HTML pageContents。我决定,我不想别名的列表,以便注释掉该code:

 < D​​IV CLASS =右三>
     < H2> {$ LANGUES [$索绪尔] ['txtAlias​​']}< / H>
     < UL类=别名>
          $ {} aliasContents
     < / UL>
< / DIV>

而与此code替换:

 < D​​IV CLASS =右三>
     < H2>您的虚拟主机和LT; / H>
     < UL类=别名>
          $ {}虚拟主机
     < / UL>
< / DIV>


解决方案

如何转动 WAMPServer2.5 我的虚拟主机的菜单?


  • 请在\\ WAMP \\ wampmanager.tpl文件的备份,以防万一你犯了一个错误,它的一个非常重要的文件。


  • 编辑\\ WAMP \\ wampmanager.tpl


  • 查找此参数; WAMPPROJECTSUBMENU ,其在[Menu.Left]部分


  • 添加此新参数; WAMPVHOSTSUBMENU 之前或之后。WAMPPROJECTSUBMENU 参数


  • 保存文件。


  • 现在的左键点击的的wampmanager图标,然后选择刷新。如果不添加菜单,退出并重新启动wampmanager。


注意
如果你已经有定义了一些虚拟主机的新的菜单才会出现!否则,你会看到没有区别,直到你定义了一个虚拟主机或两个。

哦,如果其@Bollis读这篇文章,撤消所有你做的index.php不必要的变化

There are plenty of instruction on what settings to change to show the Virtual Hosts list in the wamp homepage, however upon inspecting index.php in C://wamp/www there appeared to be no code in here to show the Virtual Hosts no matter what the settings were elsewhere. So, I have added some code in myself to show this list and thought it might help others who want to do the same.

This requires your httpd-vhosts.conf file to have entries such as the following

<VirtualHost *:80>
     DocumentRoot "C:/wamp/www/website_folder_name"
     ServerName Website_Name         #<----------This is the what index.php uses
     <Directory  "C:/wamp/www/website_folder_name">
          AllowOverride All
          Require local
     </Directory>
</VirtualHost>

Now, in C://wamp/www/index.php make the following changes:

After this line (line 65) $wampserverVersion = str_replace('"','',$result[1]);

Add:

$wampVHostsFile = $server_dir.'bin/apache/apache2.4.9/conf/extra/httpd-vhosts.conf';
if (!is_file($wampVHostsFile))
     die ('Unable to open Virtual Hosts file, please change path in index.php file');
$fp = fopen($wampVHostsFile,'r');
$wampVHostsFileContents = fread ($fp, filesize ($wampVHostsFile));
fclose ($fp);

$vHosts = "";
$result = array(1=>array(1=>786));
while(! empty($result)) {
     preg_match('|ServerName (.*)|',$wampVHostsFileContents,$result, PREG_OFFSET_CAPTURE, $result[1][1]);
     array_key_exists(1, $result) ? $vHosts .= '<li><a href="'.($suppress_localhost ? 'http://' : '').$result[1][0].'">'.$result[1][0].'</a></li>' : null;
}

if (empty($vHosts))
     $vHosts = "<li>No Virtual Hosts</li>\n";;

Then scroll to the bottom of the file and edit $pageContents containing the html. I decided I didn't want the list of aliases so comment out this code:

<div class="third right">
     <h2>{$langues[$langue]['txtAlias']}</h2>
     <ul class="aliases">
          ${aliasContents}
     </ul>
</div>

And replace with this code:

<div class="third right">
     <h2>Your Virtual Hosts</h2>
     <ul class="aliases">
          ${vHosts}
     </ul>
</div>
解决方案

How do I turn the WAMPServer2.5 My Virtual Hosts menu on?

  • Make a backup of the \wamp\wampmanager.tpl file, just in case you make a mistake, its a very important file.

  • Edit the \wamp\wampmanager.tpl

  • Find this parameter ;WAMPPROJECTSUBMENU, its in the '[Menu.Left]' section.

  • Add this new parameter ;WAMPVHOSTSUBMENU either before or after the ;WAMPPROJECTSUBMENU parameter.

  • Save the file.

  • Now left click the wampmanager icon, and select Refresh. If this does not add the menu, 'exit' and restart wampmanager.

NoteThe new menu will only appear if you already have some Virtual Hosts defined! Otherwise you will see no difference until you define a Virtual Host or two.

Oh and if its @Bollis reading this, undo all the unnecessary changes you made to index.php

这篇关于如何显示&QUOT;虚拟主机&QUOT;名单WAMP 2.5主页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 14:16