添加虚拟主机后,wamp-apache无法访问文件夹

时间:2014-03-05 23:04:48

标签: apache virtualhost wampserver

  1. 我在c:\ Windows \ System32 \ drivers \ etc \ hosts

    中添加了

    127.0.0.1 mysite.com

  2. 在httpd-vhosts.conf

    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "c:/wamp/www/sf2/web/"
    ServerName mysite.com
    
  3. 在httpd.conf中
  4. 取消注释“Include conf / extra / httpd-vhosts.conf”

  5. mysite.com运行但现在我无法访问c:\ wamp \ www中的旧文件夹

    有解决方案吗?

    “localhost / somefolder” - >打开“c:/ wamp / www / somefolder”

    “mysite.com” - >打开“c:/ wamp / www / sf2 / web /”

    同时?

1 个答案:

答案 0 :(得分:2)

添加虚拟主机时,您还必须为localhost环境创建一个。

\wamp\www文件夹结构之外创建vhost也是个好主意。我在这个例子中使用了C:\websrc\www。它确保每个站点的安全性不会与另一个站点混淆,如果您更改了wamp,则不会意外丢失站点代码。

所以在你的httpd-vhosts.conf中尝试这个

Should be first vhost so the the wamp menu page loads
Also should keep the security as this PC and internal network only

<VirtualHost *:80>
    ServerAdmin webmaster@mysite.net
    DocumentRoot "C:/wamp/www"
    ServerName localhost
    ServerAlias localhost
    <Directory  "C:/wamp/www">
        Order Deny,Allow
        Deny from all
        Allow from 127.0.0.1 localhost ::1 192.168.0
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@mysite.net
    DocumentRoot "C:/websrc/www/sf2/web"
    ServerName mysite.com
    ServerAlias www.mysite.com
    Options Indexes FollowSymLinks
    <Directory "D:/websrc/www/sf2/web">
        AllowOverride All
        Order Deny,Allow
        Deny from all
        Allow from 127.0.0.1 localhost ::1 192.168.0
    </Directory>
</VirtualHost>