How to implement “Maintenance Mode” on already established website

后端 未结 6 932
天命终不由人
天命终不由人 2020-12-04 20:33

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 adm

6条回答
  •  时光取名叫无心
    2020-12-04 21:16

    I think, standard Apache expressions are more easily to understand than rewrite rules.

    Before maintenance I rename file /home/coolcmd/site_maintenance_off to /home/coolcmd/site_maintenance_on.

    Code snippet for /.htaccess:

    # If file, directory or symlink /home/coolcmd/site_maintenance_on exists,
    # and requested file is not /maintenance.html,
    # and not an admin's IP...
    
    # Generate status code 503 for URL beginning with /, in other words for ANY URL.
    # This is not "the real redirection 3xx".
    Redirect 503 "/"
    # This page handles status code 503. All external resources used by page
    # (for example, maintenance.css), if any, must be added to  above.
    ErrorDocument 503 /maintenance.html
    # Maintenance probably will end in 10 minutes.
    Header set Retry-After 600
    
    

提交回复
热议问题