I have built a website (PHP) with more than 60 pages. I have only now realized (unfortunately) that I should have built in an "In Maintenance Mode" feature to allow an admin to temporarily disable the website and point it to a Maintenance Mode page. This would only allow those logged in as an admin to view the website.
The options I see are:
Add a new "include" file to the top of every single PHP page.
I have one include that is used to display the navigation bar on
every page (navigation class). I could write the Maintenance Mode
code in this class.
Do I have any other options? The 1st option doesn't seem like the most efficient, and the 2nd one just seems like bad programming. Is there any other better way to include a new file on every single php file?
Thanks!
ps - the site is not launched yet
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