//The solution. To solve this problem, we use the power of the .htaccess file. Just follow the steps below to get started.
//Create your maintenance page. A simple WordPress page is generally sufficient.
//Find your .htaccess file (located at the root of your WordPress installation) and create a back-up.
//Open your .htaccess file for editing.
//Paste the following code:
RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.html$
RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123
RewriteRule $ /maintenance.html [R=302,L]
//Replace 123\.123\.123\.123 on line 3 with your IP address (Don’t know it?). Make sure to use the same syntax.
//Now, all visitors except you will be redirected to your maintenance page.
//Once you’re done tweaking, upgrading, theme switching or whatever, re-open your .htaccess file and remove (or comment out) the redirection