groups

info

The .htaccess file, which controls the Apache Web server, is very useful for these kinds of tasks. In this example, we state that any visitor who has an IP different from 123.123.123.123 (which doesn’t request maintenance.html) should be redirected to maintenance.html. By replacing 123.123.123.123 with your own IP address, you make sure you’re still allowed to browse your blog normally, while others are redirected to maintenance.html.


Link to this snippet:


Download to Code Collector

language: HTML
licence: BSD

Create A Maintenance Page For Your WordPress Blog

options: send to code collectorview all maeghan's snippets
//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 
//code.