Apache禁用测试页(默认页)

在CentOS中安装apache并启动后,默认CentOS会为Apache添加一个测试页面,安装完毕并且对Apache的保持默认配置,之后在浏览器中输入你的站点的域名或ip地址,浏览器会打开如下界面

在此输入图片描述

该界面是用来测试Apache服务器是否工作正常。

禁用该测试页面的方法如下:

1.打开终端,登陆到CentOS上

2.在终端中输入以下命令

cd /etc/httpd/conf.d

3.继续输入命令,显示当前目录下的文件

ls

4.找到名为welcome.conf的文件,并用vim打开

vim welcome.conf

welcome.conf的内容如下

# 
# This configuration file enables the default "Welcome"
# page if there is no default index page present for
# the root URL.  To disable the Welcome page, comment
# out all the lines below.
#
<LocationMatch "^/+$">
    Options -Indexes
    ErrorDocument 403 /error/noindex.html
</LocationMatch>

文件中的说明性内容说明了该文件的主要作用,以及关闭该作用的方法。其实该文件也是一个普通的配置文件,并被包含进了Apache服务器httpd.conf主文件中,只要用"#"将welcome.conf的内容注释掉即可,如下:

# 
# This configuration file enables the default "Welcome"
# page if there is no default index page present for
# the root URL.  To disable the Welcome page, comment
# out all the lines below.
#
#<LocationMatch "^/+$">
#    Options -Indexes
#    ErrorDocument 403 /error/noindex.html
#</LocationMatch>

5.重新启动Apache

service httpd restart

:查看noindex.html为存放路劲

cd /var/www/error/
ls
  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值