-
Notifications
You must be signed in to change notification settings - Fork 26
/
maintenance.htaccess.template
25 lines (20 loc) · 1.18 KB
/
maintenance.htaccess.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<IfModule mod_headers.c>
# Always issue cache-killing headers - the redirects might be removed at any time.
Header always set Cache-Control "no-cache, max-age=0, must-revalidate, no-transform"
</IfModule>
RewriteEngine On
# Temporarily redirect all requests by injecting "website-under-maintenance" string into the URL.
# We can't resend POST requests so we will just send these ones back to homepage.
RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/website-under-maintenance/
RewriteCond %{THE_REQUEST} ^POST
RewriteRule ^.*$ /website-under-maintenance/ [redirect=302,last,ne]
# For all other requests the original URL is preserved and can be used to return the user to the desired location.
RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/website-under-maintenance/
RewriteRule ^.*$ /website-under-maintenance%{REQUEST_URI} [qsa,redirect=302,last,ne]
# Finally, serve maintenance page with the 200 code, so that monitoring tools don't report the downtime.
RewriteCond %{REQUEST_URI} ^/website-under-maintenance/
RewriteRule ^.*$ maintenance.html [qsa,last]