AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 760881
Accepted
adbdkb
adbdkb
Asked: 2023-11-08 04:50:19 +0800 CST2023-11-08 04:50:19 +0800 CST 2023-11-08 04:50:19 +0800 CST

如何为/var/www/html下的每个目录生成index.html

  • 772

我已经在目录下下载了用于升级的confluence软件/var/www/html。我需要为每个目录创建一个index.html 来列出目录。我尝试将以下内容添加到.htaccess目录中的文件中(我在某个地方看到了它,index.html目录中存在文件),但它不起作用:

RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]

有没有实用程序或工具可以让我做到这一点?有人让我手动创建它,但我真的不想手动创建它。

更新

@Ipor Sircer / @Marcus Müller

我更新了httpd.conf文件 - 现在如下所示:

# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/var/www/html"

#
# Relax access to content within /var/www.
#
<Directory "/var/www">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>

# Further relax access to the default document root:
<Directory "/var/www/html">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options +Indexes +FollowSymLinks
    IndexOptions +FancyIndexing +HTMLTable

    #Options None

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    #AllowOverride None
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

这是在/var/www/html:

pwd
/var/www/html

drwxr-xr-x 5 root root  86 Nov  7 18:10 .
drwxr-xr-x 4 root root  33 Aug 12 15:33 ..
drwxr-xr-x 4 root root  46 Nov  6 13:35 clients
drwxr-xr-x 3 root root  55 Nov  6 19:52 packages.confluent.io
drwxr-xr-x 3 root root  17 Nov  6 15:57 rpm

但是当我访问服务器时,我得到以下信息:

http://服务器

而如果我去server/rpm,我会得到这个:

http://服务器/rpm

我还需要更改什么才能/var/www/html从浏览器中看到下面的目录?

apache-httpd
  • 1 1 个回答
  • 65 Views

1 个回答

  • Voted
  1. Best Answer
    ajmeese7
    2023-11-08T08:36:57+08:002023-11-08T08:36:57+08:00

    按照建议,您可以像在更新的配置中一样@Ipor Sircer使用:FancyIndexing

    <Directory "/var/www/html">
        Options +Indexes +FollowSymLinks
        IndexOptions +FancyIndexing +HTMLTable
    </Directory>
    

    您可以在此处详细了解此选项的作用。但是,如果您没有启用 Apache 模块,这可能不起作用。

    要在 Apache 配置中启用该mod_autoindex模块,请运行命令sudo a2enmod autoindex,然后使用 重新启动 Apache sudo systemctl restart apache2。然后您当前的配置应该根据需要显示目录内容。


    更新:我的错误a2enmod是debianism。您可以通过以下方式mod_autoindex在 RHEL 上启用:

    1. sudo nano /etc/httpd/conf/httpd.conf
    2. 在配置文件中,查找LoadModule包含加载各种 Apache 模块的指令的部分。添加以下行以启用mod_autoindex:
    LoadModule autoindex_module modules/mod_autoindex.so
    
    1. 保存并退出CTRL+x并确认y
    2. 重新启动阿帕奇sudo systemctl restart httpd

    然后mod_autoindex 应该在您的系统上启用。


    更新 2:尝试按照这篇文章中的说明进行操作,其中涉及删除welcome.conf文件并再次重新启动服务。

    • 1

相关问题

  • 由于密码,httpd 服务器不兼容

  • Apache 日志 - X-Forwarded-for 与 Virtualhost 一起不记录

  • Apache Common Document root ,不同的虚拟主机,不同的可访问文件

  • apache httpd 指定 CipherSuite

  • 带有 apache2 配置路径错误的 SVN

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve