Question

My application is fully built now. But at times i need to bring it down for maintenance. So i created a .htaccess file and now when users try to open the application they get redirected to a different page with a maintenance image in it. The problem is after the superadmins are done with the maintenance, they need to check if the app is working fine now. But there is no way to do that as even they get navigated to the maintenance page. One of the solution is to create a testing environment. But is their any other easy solution ?

Was it helpful?

Solution

If you have some Static IP's in the .htaccess file you can try doing:

RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^11\.111\.111\.111
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteRule ^(.*)$ http://domain.com/maintenance.html [R=307,L]

Ypu can specify several REMOTE_ADDR lines for more than 1 'admin' ip if needed.

This will send anyone with IP's NOT mentioned to the maintenance page.

An ALTERNATIVE is to handle the maintenance mode within PHP... basically then you can have a list of IP's in a php script and show maintanance page or run app as normal... obviously such solution would need to be properly placed in the flow of you're code and some simple mechanism to enable/disable the site.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top