WordPress maintenance mode .htaccess

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.

Leave a Comment