Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
I don't know if recommendable, but certainly interesting. Thanks for sharing! –  brasofilo Jul 13 '13 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 '13 at 0:00
1  
@brasofilo ok :) I clarified what I mean once more. –  Marcel Jul 14 '13 at 0:18
1  
Marcel, take a look at this answer, as well as on this answer. –  kaiser Jul 14 '13 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 '13 at 2:04
show 5 more comments

1 Answer

up vote 4 down vote accepted

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.)

$currentURL = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
    if (strpos($currentURL, 'wp-admin' ) or  strpos($currentURL, 'wp-login' )) {
                    header( 'Location: '.site_url() );
}

Caution: this stops you from logging in also.

Edit:

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() ) );
} );
share|improve this answer
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). –  Ronburgundy Jul 14 '13 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 '13 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 '13 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. –  Ronburgundy Jul 14 '13 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 '13 at 10:29
show 4 more comments

Your Answer

 
discard

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.