Reputation: 225
I was wondering if in the .htaccess file I could have a check to see if a website is down. I found something that will redirect it to the maintenance mode but I don't want to have to go in and add that every time. I have a script that will run and update my live site from a repository. Is there a way to detect this update and automatically put the site in maintenance mode?
#This will redirect the site to maint mode/
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/maint\.html$
RewriteRule ^(.*)$ http://website.com/maint.html [R=307,L]
Upvotes: 0
Views: 825
Reputation: 23749
The script can create a file when it starts and you can check file existence in htaccess and redirect. When the script finishes - it will delete the file.
RewriteCond some_unique_name -f
RewriteCond %{REQUEST_URI} !^/maint\.html$
RewriteRule .* http://website.com/maint.html [R=307,L]
No need for brackets here.
Upvotes: 1