2015-09-25 99 views
3

htaccess为apache服务器导致我的所有IIS服务器都将停机维护。我需要将所有内容重定向到错误503自定义页面,并返回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错误页面,也返回错误代码。

回答

1

您可以使用否定:

RewriteEngine on 

ErrorDocument 503 /503.html 

RewriteRule !^503\.html$ - [L,NC,R=503] 
1

您在第二个规则集中使用了两个锚点。这会是这么简单:

RewriteEngine on 
RewriteBase/

ErrorDocument 503 /503.html 

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

感谢,这工作太 – Dracke

相关问题