如何在WAMP Server 3的虚拟主机中启用目录列表

时间:2016-04-01 19:37:37

标签: php apache .htaccess wamp virtualhost

我在本地计算机上使用 wamp server 3 。每当我创建一个虚拟主机时,我必须提供至少一个index.php文件来访问我的项目目录,如果没有它,我会收到404错误。

但我也希望在不提供index文件的情况下访问我的项目目录。我喜欢在服务器找不到索引文件时查看目录列表。如下图所示:

enter image description here

我认为问题出在我的httpd-vhost.conf文件中。以下是我要启用目录列表的目录的虚拟主机配置:

<VirtualHost *:80>
    ServerName virtualhost.info
    DocumentRoot c:/wamp64/www/virtual_host_test
    <Directory  "c:/wamp64/www/virtual_host_test/">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

非常感谢任何帮助。

3 个答案:

答案 0 :(得分:6)

找到一个解决方案。

默认情况下,New Wamp会禁用Fancy目录列表。

编辑C:\ wamp64 \ bin \ apache \ apache2.4.17 \ conf \ httpd.conf

需要加载此模块(删除#)

LoadModule autoindex_module modules/mod_autoindex.so

需要加载此conf(删除#)

Include conf/extra/httpd-autoindex.conf

参考链接:WAMP is not displaying the icons in the directory listing

由于

答案 1 :(得分:0)

试试这个......

import java.util.Scanner;

public class Population
{
    public static void main(String[] args)
    {
        double growthRate=-1;
        int population=0;
        int days=-1;
        double popResult=0;

        Scanner keyboard=new Scanner(System.in);

        System.out.println("\nEnter the starting number of organisms:");
        population=keyboard.nextInt();

        while(population<2)
        {
            System.out.println("\nError!! Please re-enter number of organisms.");
            population=keyboard.nextInt();
        }

        System.out.println("\nEnter rate of growth as percentage:");
        growthRate=keyboard.nextInt();

        while(growthRate<0)
        {
            System.out.println("\nError!! Growth rate must be a positive number. Please re-enter.");
            growthRate=keyboard.nextInt();
        }

        System.out.println("\nEnter number of days organisms will grow:");
        days=keyboard.nextInt();

        while(days<0)
        {
            System.out.println("\nError!! Number of days cannot be less than 1. Please re-enter.");
            days=keyboard.nextInt();
        }

        System.out.println("Days" + "\t" +  "Organisms");
        System.out.println("------------------");

        popResult=population;
        growthRate=growthRate/100;

        for(int numberOfDays=1; numberOfDays<days; numberOfDays++)
        {
            System.out.println(numberOfDays + "\t" + popResult);
            popResult=(popResult * growthRate) + popResult;

        }}}

请注意<VirtualHost *:80> ServerName virtualhost.info DocumentRoot c:/wamp64/www/virtual_host_test <Directory "c:/wamp64/www/virtual_host_test/"> Options +Indexes +FollowSymLinks +MultiView AllowOverride All Require local </Directory> </VirtualHost> 选项开头的+。你也应该阅读这篇文章。

https://wiki.apache.org/httpd/DirectoryListings

答案 2 :(得分:0)

如果您要启用目录浏览,只需在 VirtualHost

下执行此操作
Options +Indexes +FollowSymLinks +MultiViews
#Options -Indexes

,要禁用此功能,您只需反转:

#Options +Indexes +FollowSymLinks +MultiViews
 Options -Indexes