Sometimes I have to work on WordPress sites that are too busy to display the admin interface. This can happen if there’s more traffic than the server can cope with. In such cases, we may need to tell every visitor to come back later while we carry out some maintenance.
But how? Thanks to an Apache command to block all IP addresses, except for our own. We can even display a “maintenance” page while we’re hard at work behind the scenes.
Let’s see how. Add the following to your .htaccess file in the web root directory, replacing 22.214.171.124 with your own IP address:
ErrorDocument 403 /maintenance.html Order Allow,Deny Allow from 126.96.36.199
Save the file on the server and see the site speed up as of by magic. No more requests but your own shall be processed henceforth.
Thanks to MickeyRush and b101101011011011 for this solution on Stack Overflow:
How do I find my own IP?
There are several services that will display the IP you’re currently connecting from. Head over to http://whatsmyip.org, or type “my ip” into Google.
Does this work with NGINX too
I’m sure the principle does, but I know very little about NGINX configuration. The above directive is for Apache only. If you know how this works in NGINX, please leave a comment below.