Last summer I created a travelling-blog on my webspace to document my journey. Now the journey is over and I won't put any new posts in this blog. I also don't whish to have any new comments.

How can I close the blog (to make in invulnerable to external hacks, even if I don't install any new upgrades) but keep all posts, comments, pictures, etc. as they are?

What I found is

Is one of them recommendable?

Is there another way to prevent all interactions with the page, so there's no need to take care about wordpress (or plugin) updates, while still keeping the site secure?

  • I don't know if recommendable, but certainly interesting. Thanks for sharing!
    – brasofilo
    Jul 13, 2013 at 23:09
  • 1
    If any of those tools generates a quality mirror static site, that's one thing, and covers the "How to close the blog" part of your Q. The other thing is "Is a static site immune to hacks?". And maybe you should research/ask at Webmasters. Unless a more experienced user jumps in and gives a full Answer.
    – brasofilo
    Jul 14, 2013 at 0:00
  • 1
    @brasofilo ok :) I clarified what I mean once more.
    – Marcel
    Jul 14, 2013 at 0:18
  • 1
    Marcel, take a look at this answer, as well as on this answer.
    – kaiser
    Jul 14, 2013 at 2:01
  • 1
    Marcel, just to note that: Any answer (incl. my links), only prevent someone from reaching the login form. Better - imo - would be to simply use a .htaccess-rule to prevent access to the wp-login.php and similar sites. This as well prevents PHP from even firing up, so it might be (A) the simplest and (B) the most resource efficient solution.
    – kaiser
    Jul 14, 2013 at 2:04

1 Answer 1


Why not just disable comments and registration?

This comes to mind also:

(Redirect all requests to login page or admin pages to homepage. A little irreversible.)

    if (strpos($currentURL, 'wp-admin' ) or  strpos($currentURL, 'wp-login' )) {
                    header( 'Location: '.site_url() );

Caution: this stops you from logging in also.


And adaptation of the above code put into plugin format can be found here. Thanks to brasofilo.

Modified code:

add_action( 'init', function()
    $currentURL = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
    if( strpos( $currentURL, 'wp-admin' ) or strpos( $currentURL, 'wp-login' ) )
        exit( wp_redirect( site_url() ) );
} );
  • 1
    You can throw this into the very bottom of your functions.php file of your theme. Like I said tho, this will totally prevent you from logging in to edit anything ever. So you would have to FTP into your server and edit your functions.php to regain access in the future (Or cause wordpress to change the theme).
    – Vigs
    Jul 14, 2013 at 0:30
  • 1
    A Must Use plugin is the earliest place to put this code. @Ronburgundy, ain't your example doing a loop? I guess a simple site_url() does the job, no?
    – brasofilo
    Jul 14, 2013 at 0:38
  • 2
    @Marcel, I wrote down a mini-plugin adapting Ronburgundy's code. With fast tests, it works ok. Ron, feel free to add it to your Q.
    – brasofilo
    Jul 14, 2013 at 0:48
  • 1
    A plugin would probably be a better place for this. And yes site_url() would probably be best. I sometimes look to avoid wp functions and use straight php when I want to be sure an action is going to occur. I have had trouble with wp_redirect() not functioning as expected in the past so I chose to avoid it in this case. But it does suite here. Bras, if your referring to the lack of the use of exit; after header(), I was / am not aware that it was necessary, but i am aware that its required after wp_redirect.
    – Vigs
    Jul 14, 2013 at 3:11
  • 1
    @Ronburgundy Hint: Never use anonymous functions in WP. They're a pain in callback hell and nearly impossible to debug as you'll never find them. Always use a real callback.
    – kaiser
    Jul 14, 2013 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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