-
Put
maintenance.html
into your root directory -
Open
.htaccess
file -
Insert this block in the first line of the file
ErrorDocument 503 /maintenance.html <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_URI} !=/maintenance.html RewriteCond %{REMOTE_ADDR} !=127.0.0.1 RewriteRule ^.*$ - [R=503,L] </IfModule>
-
Replace
127.0.0.1
to your ip address -
Done! Users except you will be redirected to maintenance.html
ErrorDocument 503 /maintenance.html
is when user gets error 503, redirect the page to maintenance.html
RewriteRule ^.*$ - [R=503,L]
does rewrite any url without replacing the url and access with 503
Hello, nice function. I try it for my use-case, but it does not work as expected.
I add some line of codes to exlude the pictures fro the maintenance page and also exclude the healthcheck file for the loadbalancer check. Theres requests should not be redirected to the maintenance page.
` # Redirect all request to a 503 return code when in maintenance mode
It works, if I access the webpage in root, means http://localhost then I will redirected to the maintenance page. But If I call the page in subfolder, http://localhost/admin I see the text of my maintenance page, but the images are not displayed.