gpt4 book ai didi

apache - 将除一页以外的所有页面重定向到错误 503 自定义页面

转载 作者:行者123 更新时间:2023-12-04 02:18:13 26 4
gpt4 key购买 nike

用于 apache 服务器的 htaccess 导致我所有的 IIS 服务器都将在维护时关闭。我需要将所有内容重定向到错误 503 自定义页面并返回 503 错误,但我不知道正确的解决方案。

RewriteEngine on
RewriteBase /

ErrorDocument 503 /503.html

RewriteRule ^.*$ - [L,NC,R=503]

这个结果变成了:(这个响应不是我的自定义响应)

Service Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

另一个尝试:

RewriteEngine on
RewriteBase /

ErrorDocument 503 /503.html

RewriteRule ^(?!503.html)$ - [L,NC,R=503]

给我我需要的东西,但只是 www.domain.com 和所有其他页面给我 404(除了 www.domain.com/503.html 给我 200)。

所以我需要的是将除 domain.com/503.html 之外的所有页面重定向到自定义 503 错误页面并返回错误代码。

最佳答案

您在第二个规则集中使用了两个 anchor 。就这么简单:

RewriteEngine on
RewriteBase /

ErrorDocument 503 /503.html

RewriteRule ^(?!503.html).* - [R=503,L,NC]

关于apache - 将除一页以外的所有页面重定向到错误 503 自定义页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32778357/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com