How to implement Maintenance Mode on already established website
You can use .htaccess
to redirect to another page while on Maintenance Mode.
Three assorted examples:
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^11\.111\.111\.111
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteRule ^(.*)$ http://domain.com/maintenance.html [R=307,L]
.htaccess “Down For Maintenance” Page Redirect
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.html$
RewriteCond %{REMOTE_HOST} !^888\.888\.888\.888
RewriteRule $ /maintenance.html [R=302,L]
Redirect to maintenance page during upgrade using .htaccess
# redirect all visitors to alternate site but retain full access for you
ErrorDocument 403 http://www.alternate-site.com
Order deny,allow
Deny from all
Allow from 99.88.77.66
Maintenance mode for apache
how to set maintenance mode for entire website with htaccess
i find out an blog that contains answer for your question please check this site
The below examples are taken from the above mentioned site.
If you don’t already have an .htaccess file in the root of your
domain, create one and add the following code. If you already have an
.htaccess file, add the following code in front of everything that
might be in there
RewriteEngine On
# Add all the IP addresses of people that are helping in development
# and need to be able to get past the maintenance mode.
# One might call this the 'allow people list'
RewriteCond %{REMOTE_HOST} !^83\.101\.79\.62
RewriteCond %{REMOTE_HOST} !^91\.181\.207\.191
# Make sure the maintenance mode only applies to this domain
# Example: I am hosting different sites on my server
# which could be affected by these rules.
RewriteCond %{HTTP_HOST} ^nocreativity.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.nocreativity.com$
# This is the 'ignore file list'. It allows access to all
# files that are needed to display the maintenance mode page.
# Example: pages, css files, js files, images, anything.
# IMPORTANT: If you don't do this properly, visitors will end up with
# endless redirect loops in their browser.
RewriteCond %{REQUEST_URI} !/offline\.htm$
RewriteCond %{REQUEST_URI} !/css\/style\.css$
RewriteCond %{REQUEST_URI} !/images\/logo\.png$
# Rewrite whatever request is coming in to the maintenance mode page
# The R=302 tells browsers (and search engines) that this
# redirect is only temporarily.
# L stops any other rules below this from executing whenever somebody is redirected.
RewriteRule \.*$ /offline.htm [R=302,L]
How to put an asp.net application into offlince/maintenance mode?
This is the answer to your question:
http://www.codeproject.com/Tips/219637/Put-the-website-in-Maintanance-Mode-Under-Construc
How to put a React app in maintenance mode
You can create a component that will have the content to show when the application is in maintenance mode, and use it as the only component to be rendered in case of maintenance else other/normal behavior components. codesandbox-demo
How to use a maintenance.php file inside a WordPress theme?
When WordPress goes into maintenance mode, it adds a file named .maintenance
to the root directory while the maintenance is being performed, then it's removed afterwards. You can write a function inside your theme's functions.php
that checks for this file and loads a custom maintenance page from the theme.
if ( ! function_exists( 'wpse84987_maintenance_mode' ) ) {
function wpse84987_maintenance_mode() {
if ( file_exists( ABSPATH . '.maintenance' ) ) {
include_once get_stylesheet_directory() . '/maintenance.php';
die();
}
}
add_action( 'wp', 'wpse84987_maintenance_mode' );
}
Put your maintenance content in the maintenance.php
page inside your theme folder and you're all set to style it however you would like.
If you use the wp_die
function, you'll get the standard white box on grey background. This way lets you style your maintenance page like you would any other theme page.
You can also do this outside the theme by adding maintenance.php
to the wp-content
directory (or wherever you've set WP_CONTENT_DIR
to point to) as a drop-in plugin. When WP checks for maintenance mode from inside wp_maintenance()
it'll look for that file and load it if present, or load its own if not. If the site isn't in maintenance mode, or is in it for more than 10 minutes, 'maintenance.php' won't load even though the site is technically still in maintenance mode. WordPress 4.6 introduces the 'enable_maintenance_mode'
filter, which can be (ab)used by a tool like wp-cli
to force the check for the drop-in and would let you run a CLI command from your maintenance file.
With Wordpress in Maintenance Mode, how do we exclude the wp-login.php page?
Using $wp->request you should be able to add an exclusion for the wp-login page to your if(!is_user_logged_in() && !is_admin()) {
statement to prevent the code from loading there.
You also need to use home_url( $wp-request ) inside a function call. The code for this would be like this here:
add_action('pre_get_posts', 'maintenance_mode_logic');
function maintenance_mode_logic() {
global $wp;
$config = get_field('website', 'option');
if($config["status"] == 1) {
//echo 'hello';
//exit();
add_filter( 'wp_die_handler', '_custom_wp_die_handler' );
}else {
if(!is_user_logged_in() && !is_admin() && home_url( $wp->request ) != wp_login_url()) {
maintenance_mode();
}
}
}
Related Topics
How Is MVC Supposed to Work in Codeigniter
How to Check If an Entered Value Is Currency
Decoding Numeric HTML Entities via PHP
How to Keep the Chinese or Other Foreign Language as They Are Instead of Converting Them into Codes
PHP Adds Keys to Decoded and Then Encoded JSON Data
Storing and Retrieving an Array in a PHP Cookie
How to Change Default Redirect Url of Laravel 5 Auth Filter
Check If a Remote Page Exists Using PHP
Is This a PHP Date() Bug, or Is There Something Wrong with My Code
Setting Up a Cronjob in Windows Xampp
How to Set an Absolute Include Path in PHP
Group MySQL Results by Category and Display Them into Groups Under Each Category
What Are the Risks of PHP Sessions
Vcruntime140.Dll 14.0 Not Compatible with PHP Build
Generating Ssh Keys for 'Apache' User
Using Websocket on Apache Server
Strategy to Override a Class in a Library Installed with Composer