Dear Wiki user, You have subscribed to a wiki page or wiki category on "Httpd Wiki" for change notification.
The "MaintenancePage" page has been changed by SeanTimmins: https://wiki.apache.org/httpd/MaintenancePage New page: = Recipes for Implementing a Maintenance Page = It is relatively common for Apache httpd users to wish to serve a standard page while underlying software deployments are occurring or even if the site is down temporarily for whatever reason. Below are details some of the methods by which this can be achieved. All recipes share in common that you redirect to a page served with a 503 return code to prevent search engines indexing the maintenance page. == Touch a File Method == This recipe is good in that it can almost trivially be programmed in a shell script or similar. Maintenance is enabled by 'touching' a single file on the file system and disabled by removing that file. In this example a generic piece of Apache configuration allows either individual virtual hosts to be put into maintenance mode, or the whole servers. In practice, especially with a large number of virtual host, the maintenance configuration could be split out into an [[https://httpd.apache.org/docs/current/mod/core.html#include|Include]] file. What is not included below is the configuration to enable the serving of the URI {{{/maintenance/index.html}}} itself as a page. {{{ <VirtualHost *:8080> ServerName myfirstdomain.com DocumentRoot "/var/www/myfirstdomain/htdocs" # Redirect all request to a 503 return code when in maintenance mode ErrorDocument 503 /maintenance/index.html RewriteEngine on RewriteCond /var/www/maintenance/ALL -f [OR] RewriteCond /var/www/maintenance/%{SERVER_NAME} -f RewriteCond %{REQUEST_URI} !=/maintenance/index.html RewriteRule ^ - [R=503,L] # Redirect away from the maintenance page if not in maintenance mode RewriteCond /var/www/maintenance/ALL !-f RewriteCond /var/www/maintenance/%{SERVER_NAME} !-f RewriteRule ^/maintenance/index.html$ / [R,L] </VirtualHost> <VirtualHost *:8080> ServerName myseconddomain.com DocumentRoot "/var/www/myseconddomain/htdocs" # Redirect all request to a 503 return code when in maintenance mode ErrorDocument 503 /maintenance/index.html RewriteEngine on RewriteCond /var/www/maintenance/ALL -f [OR] RewriteCond /var/www/maintenance/%{SERVER_NAME} -f RewriteCond %{REQUEST_URI} !=/maintenance/index.html RewriteRule ^ - [R=503,L] # Redirect away from the maintenance page if not in maintenance mode RewriteCond /var/www/maintenance/ALL !-f RewriteCond /var/www/maintenance/%{SERVER_NAME} !-f RewriteRule ^/maintenance/index.html$ / [R,L] </VirtualHost> }}} The downside to this recipe is that it incurs file system checks for all requests hitting your web server, so careful testing is required. == IfDefine Method == This recipe requires that you modify apachectl to cope with 'enabling/disabling' maintenance. The downside is that it requires a full stop/start since you cannot pass a directive that is interpreted by [[https://httpd.apache.org/docs/2.2/mod/core.html#ifdefine|IfDefine]] with a restart. {{{ <VirtualHost *:8080> ServerName myfirstdomain.com DocumentRoot "/var/www/myfirstdomain/htdocs" <IfDefine Maintenance> ErrorDocument 503 /maintenance/index.html RewriteEngine on RewriteCond %{REQUEST_URI} !=/maintenance/index.html RewriteRule ^ - [R=503,L] </IfDefine> <IfDefine !Maintenance> RewriteEngine on RewriteRule ^/maintenance/index.html$ / [R,L] </IfDefine> </VirtualHost> <VirtualHost *:8080> ServerName myseconddomain.com DocumentRoot "/var/www/myseconddomain/htdocs" <IfDefine Maintenance> ErrorDocument 503 /maintenance/index.html RewriteEngine on RewriteCond %{REQUEST_URI} !=/maintenance/index.html RewriteRule ^ - [R=503,L] </IfDefine> <IfDefine !Maintenance> RewriteEngine on RewriteRule ^/maintenance/index.html$ / [R,L] </IfDefine> </VirtualHost> }}} And then the following addition to the {{{case}}} statement: {{{ maintenance) $HTTPD -k stop $HTTPD -D Maintenance -k start ;; }}} --------------------------------------------------------------------- To unsubscribe, e-mail: docs-unsubscr...@httpd.apache.org For additional commands, e-mail: docs-h...@httpd.apache.org