Question

I have tried multiple ways to host a maintenance page while I update a WordPress blog but to no avail. I get an Internal Server Error.

RewriteEngine On

# Add all the IP addresses of people that are helping in development
# and need to be able to get past the maintenance mode.
# One might call this the 'allow people list'
RewriteCond %{REMOTE_HOST} !^83\.101\.79\.62
RewriteCond %{REMOTE_HOST} !^91\.181\.207\.191

# Make sure the <em>maintenance mode</em> only applies to this domain
# Example: I am hosting different sites on my server
# which could be affected by these rules.
RewriteCond %{HTTP_HOST} ^nocreativity.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.nocreativity.com$

# This is the 'ignore file list'. It allows access to all
# files that are needed to display the <em>maintenance mode</em> page.
# Example: pages, css files, js files, images, anything.
# IMPORTANT: If you don't do this properly, visitors will end up with
# endless redirect loops in their browser.
RewriteCond %{REQUEST_URI} !/offline\.htm$
RewriteCond %{REQUEST_URI} !/css\/style\.css$
RewriteCond %{REQUEST_URI} !/images\/logo\.png$

# Rewrite whatever request is coming in to the <em>maintenance mode</em> page
# The R=302 tells browsers (and search engines) that this
# redirect is only temporarily.
# L stops any other rules below this from executing whenever somebody is redirected.
RewriteRule \.*$ /offline.htm [R=302,L]

The code above is from No Creativity

I've also tried...

# MAINTENANCE-PAGE REDIRECT
<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{REMOTE_ADDR} !^123\.456\.789\.000
 RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
 RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
 RewriteRule .* /maintenance.html [R=302,L]
</IfModule>

... from WP Beginner

Is there any issue with just changing the name of index.php in the top directory to _index.php and renaming my maintenance.html file to index.php?

Was it helpful?

Solution 2

RewriteEngine On

# Add all the IP addresses of people that are helping in development
# and need to be able to get past the maintenance mode.
# One might call this the 'allow people list'
RewriteCond %{REMOTE_HOST} !^111\.222\.333\.444

# Make sure the <em>maintenance mode</em> only applies to this domain
# Example: I am hosting different sites on my server
# which could be affected by these rules.
RewriteCond %{HTTP_HOST} ^yourdomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.yourdomain.com$

# This is the 'ignore file list'. It allows access to all
# files that are needed to display the <em>maintenance mode</em> page.
# Example: pages, css files, js files, images, anything.
# IMPORTANT: If you don't do this properly, visitors will end up with
# endless redirect loops in their browser.
RewriteCond %{REQUEST_URI} !/maintenance\.html$
RewriteCond %{REQUEST_URI} !/somejavascriptfile\.js$
RewriteCond %{REQUEST_URI} !/css\/yourstylesheet\.css$
RewriteCond %{REQUEST_URI} !/img\/yourlogo\.jpg$

# Rewrite whatever request is coming in to the <em>maintenance mode</em> page
# The R=302 tells browsers (and search engines) that this
# redirect is only temporarily.
# L stops any other rules below this from executing whenever somebody is redirected.
RewriteRule \.*$ /maintenance.html [R=302,L]

This is a sample from what I used, originally from No Creativity but for some reason didn't work.

OTHER TIPS

Another way to do it is with a temporary function in your functions.php:

function maintenance_redirect(){
    if( !is_user_logged_in() ){
        wp_redirect( site_url( 'maintenance.html' ), 302 );
        exit();
    }
}
add_action( 'init', 'maintenance_redirect' );

This would send all non-logged-in users to your maintenance page while you're free to use WordPress as normal so long as you're logged in. If you have registered users on the site, you could change the if statement to just check for administrators or even just check for one particular user.

if( !is_user_logged_in() || !current_user_can( 'manage_options' ) )...

We use this all the time - no plugins, no entries in the database, and very quick and easy to implement and remove.

Dear Mike why you are modifying your HTTP access file just go and download "WP Maintenance Mode" http://wordpress.org/plugins/wp-maintenance-mode/screenshots/

How to use this plugin:

First install this plugin in your WP website. After installation activate this plugin. Now click on setting and then set "true" at the place of "false" and you will see your website automatically run in Maintenance mode. You also can change maintenance page style from CSS Style in WP Maintenance plugin. enter image description here

If you need any other help I'm always available here to help you

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