Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

How to set a temporary holding page? WordPress



I'm trying to set a temporary holding page.

We've built a custom holding page, uploaded it (and related files) and called it maintenance.php

I found this advice online and

and followed the instructions, which are to add the following to .htaccess:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.php$
RewriteCond %{REMOTE_HOST} !^127\.0\.0\.1
RewriteRule $ /maintenance.php [R=302,L]

(inserting my IP in the code, once it works, of course).

I tried it and ... nothing happened!

Could anyone offer any advice?

Incidentally this is for a college website (it's not a marked piece of work - myself and some other students have volunteered to create a new website for the student-led uni radio station).

So, although I'm keen to learn, I'm not a professional so please bear with me if I've just missed something obvious!

The website is

I'd be grateful for any help.

Thanks :)

Answers (2)


Pixel Coder answers:

If you're using WordPress and not doing a Computing Science major you may want to look into this.

If you wanna learn to shoot web for whatever reason there are many ways to approach it.

Personally I wouldn't use an .htaccess for a maintenance page.

You can make a copy of index.php which will be in your site route, and then upload a new index.php with the content of maintenance.php.

Most servers are set up so the directoryIndex is index.php.

Working with the two options above, they are most painless imo.

Good luck

Rebecca Brueton comments:

Hi Alistair, thanks for the reply :)

I'm doing Digital Media.

Thanks for the maintenance mode suggestion but we've got a custom page, and that maintenance widget is too basic.

Since building our custom page I have found a load of free plug-ins for holding pages which do look cool though, and had we seen them last week we may well have ised one of them! However we've got something we've designed ourselves and are committed to using now.

I did wonder about simply overwriting index.php. Is it really that simple?! I'll have a go :)

Pixel Coder comments:

So you are flipping a switch in wp-admin and turning on maintenance mode?

If not, and you are manually updating files I really don't see the need for .htaccess.

Yes, it's that simple when it's on WordPress.

Pixel Coder comments:

Sorry if for SEO reasons you want a redirect then yeah actually redirect to maintenance.php may be the way. Sorry the short question got me focussed into the small part of the equation.

But again it still does lead to the if you are switching or not switching something in wp-admin through a plugin, custom field etc.

It's ultimately a redirect that's going to inform the user that the site is down.

Still though, I wouldn't use .htaccess for it lol.

if(get_post_meta($post->ID, 'maintenance', true)) :
header('location: maintenance.php');
else :
// Normal page

Rebecca Brueton comments:

That maintenance mode thing is cool, wish I'd seen it a week ago! ;)

Rebecca Brueton comments:

All I want to do is make the index page a static HTML page, with none of the headers / menus etc from the rest of the site.

I suspect I many be overcomplicating it!

<possible stupid question alert!>

This is what index.php contains

* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
* @package WordPress

* Tells WordPress to load the WordPress theme and output it.
* @var bool
define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */

Do I leave in the stuff about setting the theme (i.e. is it doing it for the whole site here) or delete it (if it's just instructing it to use the theme for this page?)

Thanks :)

Rebecca Brueton comments:

I'm not worried about any other considerations such as SEO at this point - so few people are looking at it right now it really doesn't matter until the real site goes up I reckon.

Pixel Coder comments:

What the index.php file does without going into all the details a) because i don't know them all and b) it's not really important here right now.... is build the environment by grabbing all the files and functions needed to run your WordPress site.

So if your site is down for maintenance and you're not worried about anything else but letting people know that then yes you can remove everything from that file (make a backup, to be restored when out of maintenance) and place your maintenance.php page.

If however you are looking to use some of the files in your WordPress theme as part of the maintenance page then it gets a little more complicated.

What I suggest you do is this.

Go into the page you have in wp-admin set for the home page and add a custom field.

Call it something like "maintenance".

Now within your WordPress theme, locate the template you use for the home page it might be page.php or template-home.php

Within that and within your loop paste this code.

if(get_post_meta($post->ID, 'maintenance', true)) :
header('location: /maintenance');

Assuming your have a page created in wp-admin for maintenance and you have the url structure set for %postname%.

Maybe i'm confusing things because you mentioned maintenance.php

Rebecca Brueton comments:

Thanks both of you for helping me. Dylan I used your solution in the end, but Alistair you have helped me make more sense of it, given me other solutions which will work and also given me a solution (wp maintenance mode) which will make this much easier in the future (next time unless the project calls for something bespoke, I'll just use one of their templates, much quicker!)

So many thanks to both of you! Off to try to work out / remember how to award the prize money now!


Dylan Kuhn answers:

I recently had experience with JF3 Maintenance Redirect, which lets you redirect to a static page in maintenance mode:
[[LINK href=""]][[/LINK]]

Rebecca Brueton comments:

Brilliant, that's done the trick thanks :)