WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to redirect a whole WordPress site to a single WordPress page. A sort of maintenance mode, but the redirect has to go to a published WordPress page. Unfortunately, the maintenance page I need to show has to use other WordPress plugins.

I am not aware of any Maintenance Mode plugin which lets you do this. At most, they let you write custom HTML/CSS code.

I was thinking about a .htaccess mod_rewrite rule. However, I am very weak with mod_rewrite.

First, I disabled canonical redirects.

Then, I tried to use:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/index.php?page_id=813$
RewriteRule ^(.*)$ /index.php?page_id=813 [R=307,L]

However, these rules generate redirect loops. page_id=813 is the ID of my maintenance page, of course.

Is anybody aware of a maintenance mode plugin, which redirects to a published page?

Alternatively, can somebody help me to fix the mod_rewrite rules? Extra cheers if we can leave /wp-admin out of the redirect rules.

share|improve this question
up vote 7 down vote accepted

You don't need .htaccess to do this at all. A .htaccess fix would be bloated and overloaded.

Instead, we can hook into the template_redirect filter, which only fires on the front-end (not in wp-admin). We then use the is_page() function to check if we're viewing a page with the ID of 813. If not, redirect to that page using the wp_redirect() function.

add_action( 'template_redirect', 'wpse_76802_maintance_mode' );

function wpse_76802_maintance_mode() {
    if ( ! is_page( 813 ) ) {
        wp_redirect( home_url( 'index.php?page_id=183' ) );

This will work great for a maintenance mode, as the redirect is made with the 302 'temporary' HTTP header, letting bots and search engines know that your site will be up soon. However, if you're permanently moving the site, you might want to use a 301 'permanent' HTTP header for the redirect. You can do this by adding a second parameter to the wp_redirect function. Example:

add_action( 'template_redirect', 'wpse_76802_goodbye_redirect' );

function wpse_76802_goodbye_redirect() {
    if ( ! is_page( 813 ) ) {
        wp_redirect( home_url( 'index.php?page_id=183' ), 301 );
share|improve this answer
Brilliant. Works like a charm. Cheers and thank you for enhancing the quality of my question as well. – dgraziotin Dec 21 '12 at 9:32
This works great for my purpose as well. Except adding a twist - the site is "down" for good and I want to keep WP up and running serving up the goodbye page as the home page. Is there a way to add a 301 header to this type of redirect for SEO? – Tapefreak May 24 '13 at 1:42
@Tapefreak You can set the HTTP header as the second parameter of the wp_redirect function. Example: wp_redirect( home_url( 'index.php?page_id=183' ), 301 ); – shea May 24 '13 at 3:30
@Tapefreak I've updated my answer with additional information regarding your request – shea May 25 '13 at 4:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.