Reputation: 651
htaccess for apache server cause all my IIS servers will be down on maintenance. I need to redirect everything to error 503 custom page and also return the 503 error, but I don't know the correct sollution.
RewriteEngine on
RewriteBase /
ErrorDocument 503 /503.html
RewriteRule ^.*$ - [L,NC,R=503]
This result into this: (the response is not my custom response)
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.
Another try:
RewriteEngine on
RewriteBase /
ErrorDocument 503 /503.html
RewriteRule ^(?!503.html)$ - [L,NC,R=503]
Gives me what I need but just for www.domain.com and every other page gives me 404 (except www.domain.com/503.html which gives me 200).
So what I need is to redirect every page but the domain.com/503.html to custom 503 error page and also return the error code.
Upvotes: 3
Views: 4753
Reputation: 784878
You can use negation:
RewriteEngine on
ErrorDocument 503 /503.html
RewriteRule !^503\.html$ - [L,NC,R=503]
Upvotes: 1
Reputation: 80629
You used both anchors in the second ruleset. It'd be as simple as:
RewriteEngine on
RewriteBase /
ErrorDocument 503 /503.html
RewriteRule ^(?!503.html).* - [R=503,L,NC]
Upvotes: 3