Apache 添加自定义vhost 目录,等其他配置

本文介绍如何在Apache服务器中配置404错误页面跳转到首页,并展示了如何设置自定义错误页面及使用不同HTTP状态码进行重定向的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、在 Apache 下找到 httpd.conf  ,这个文件中找到默认 Include conf/vhosts.conf   ,

在这个之后添加 Include conf/self_vhosts/*.conf

我的配置: 

Include conf/vhosts.conf
Include conf/self_vhosts/*.conf

 

2、 Apache 添加 404 跳转到首页 在 vhost 文件中添加如下

主要代码:  ErrorDocument 404 http://www.test.com

<VirtualHost *:80>
    DocumentRoot "E:/web/bj_tour_en/A206/"
    ServerName www.test.com
    ErrorDocument 404 http://www.test.com
</VirtualHost>

2-02 、 强制 Apache 返回一个404状态码 (其他http状态码)

Redirect 404 /          #访问根目录显示404
Redirect 500 /          #访问根目录显示500
<Directory /data/www>
    Deny from all   #403 拒绝访问
    #ErrorDocument 404 /test/404.html  #404 重定向
    #ErrorDocument 404 "This is 404 page"  #400 显示错误字符串
</Directory>

 

官网: Apache HTTP 服务器 2.4 文档

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值