我已经在目录下下载了用于升级的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
但是当我访问服务器时,我得到以下信息:
而如果我去server/rpm
,我会得到这个:
我还需要更改什么才能/var/www/html
从浏览器中看到下面的目录?
按照建议,您可以像在更新的配置中一样
@Ipor Sircer
使用:FancyIndexing
您可以在此处详细了解此选项的作用。但是,如果您没有启用 Apache 模块,这可能不起作用。
要在 Apache 配置中启用该
mod_autoindex
模块,请运行命令sudo a2enmod autoindex
,然后使用 重新启动 Apachesudo systemctl restart apache2
。然后您当前的配置应该根据需要显示目录内容。更新:我的错误
a2enmod
是debianism。您可以通过以下方式mod_autoindex
在 RHEL 上启用:sudo nano /etc/httpd/conf/httpd.conf
LoadModule
包含加载各种 Apache 模块的指令的部分。添加以下行以启用mod_autoindex
:CTRL+x
并确认y
sudo systemctl restart httpd
然后
mod_autoindex
应该在您的系统上启用。更新 2:尝试按照这篇文章中的说明进行操作,其中涉及删除
welcome.conf
文件并再次重新启动服务。