Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Redirect users to a maintenance.html file unless they are coming from your IP address. WordPress
/*
Lock site down to just our IP
Create a file /maintenance.html that explains that maintenance mode is on.
Update your IP address in the line below.
Add this code to your active theme's functions.php or a custom plugin.
*/
function mainenance_mode_on() {
if($_SERVER['REMOTE_ADDR'] == 'YOURIPADDRESSHERE') //find your IP and edit here
return;
wp_redirect('/maintenance.html');
exit;
}
add_action('init', 'mainenance_mode_on');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.