The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Site offline [maintenance] button.

Discussion in 'Workarounds and Optimization' started by H4CK3R, Jan 17, 2012.

  1. H4CK3R

    H4CK3R Well-Known Member

    Joined:
    Oct 14, 2011
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Website Owner
    Hi,
    What about a button in cpanel to make whole site unavailable with a custom message, "Site is currently under maintenance".

    Why:
    Every site needs some maintenance which may disturb users, so i think this option will help a lot.

    Thanks for reading.
     
  2. monarobase

    monarobase Well-Known Member

    Joined:
    Jan 26, 2010
    Messages:
    503
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    France
    cPanel Access Level:
    Root Administrator
    If you could enter your IP and activate the maintenance page for all other IP's this could be an interesting feature, and quite easy to do with an .htacess file.

    +1 for a maintenance mode that adds code to the .htaccess file to show a maintenance page to everyone except a specified list of IP's.

    As far as we are concerned, this would be an interesting feature but not high on our list of priorities !
     
  3. PlotHost

    PlotHost Well-Known Member

    Joined:
    Apr 29, 2011
    Messages:
    253
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    US
    cPanel Access Level:
    Root Administrator
    Twitter:
    Yes, this would be a nice addition ... anyway you can always just put a index.php file with "Site is currently under maintenance" text.
     
  4. H4CK3R

    H4CK3R Well-Known Member

    Joined:
    Oct 14, 2011
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Website Owner
  5. monarobase

    monarobase Well-Known Member

    Joined:
    Jan 26, 2010
    Messages:
    503
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    France
    cPanel Access Level:
    Root Administrator
    You could also just password protect the site with a title saying that the site is in maintenance mode. This way you can still access your site but others can't.
     
  6. Brian

    Brian Well-Known Member

    Joined:
    Dec 1, 2010
    Messages:
    117
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    Texas
    cPanel Access Level:
    Root Administrator
    Please note that this functionality is already inherently available via using a custom mod_rewrite rewrite rule.

    [1] Create and customize a file called: maintenance.php

    [2] Add the following to your .htaccess

    Code:
    RewriteEngine On
    RewriteRule !^maintenance.php$ /maintenance.php [R=302,L]
    
    Any accesses to any page on the site OTHER than maintenance.php will be redirected to maintenance.php. Therefore, this disables all links/pages/etc. on the site other than maintenance.php

    You can then comment out that rewrite rule as desired to enable/disable maintenance mode within seconds.

    A full on feature to automate this, while not out of the question, seems a bit heavy handed given the 2-step process to activate it as it is now. In addition, many scripts in existence already have inherent "Maintenance Mode" functions within them.

    EDIT
    To address monarobase's request to allow maintenance mode to "exempt" certain IPs, you could modify Step 2 to the following rule:

    Code:
    RewriteEngine On
    RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123$
    RewriteCond %{REMOTE_ADDR} !^100\.100\.
    RewriteRule !^maintenance.php$ /maintenance.php [R=302,L]
    
    And so on. The above would exempt "123.123.123.123" and "100.100.*.*" from the rewrite and thus allow them to access the site. This admittedly can be a bit more complex since you need some basic Regular Expressions knowledge, but is still readily possible with cPanel as it stands right now.
     
    #6 Brian, Jan 21, 2012
    Last edited: Jan 21, 2012
  7. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,450
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Moved to Workarounds forum.
     
  8. H4CK3R

    H4CK3R Well-Known Member

    Joined:
    Oct 14, 2011
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Website Owner
    Yes, it worked, thanks.
    But, what about subdomains? Do i have to add these lines to all .htaccess files of all subdomains?
    And, i also need to ask one more question, should i ask here or create a new topic?
    Question: I have a file, and i want to copy it to my all subdomains, (14 subdomains ) , i have to copy one by one, is there any way that i can copy to all at once?
    Thanks.
     
  9. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,450
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Different topic, different thread is always the best way to go. ;)
     
  10. Indianets

    Indianets Well-Known Member

    Joined:
    Jun 13, 2008
    Messages:
    65
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    Interesting! :)

    In /home/USER/.htaccess (note that not in public_html)

    Code:
    <Files *>
    Order Deny,Allow
    Deny From All
    Allow From x.x.x.x
    </Files>
    
    ErrorDocument 403 "The Site is down for maintenance! Please come back later!"
    
    Easy! No?

    - Vijay :D
     
  11. H4CK3R

    H4CK3R Well-Known Member

    Joined:
    Oct 14, 2011
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Website Owner
  12. SoftDux

    SoftDux Well-Known Member

    Joined:
    May 27, 2006
    Messages:
    983
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Johannesburg, South Africa
    cPanel Access Level:
    Root Administrator
    Does anyone know of a workaround to have this feature enabled, but not allow the end user to disable the "maintenance mode" on their website?

    i.e. let's say a website is defaced, I want their account to still be active for emails to work, but the website should be unavailable, till such a time as when the user fix or re-upload their website to the server
     
  13. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    You could have a cron periodically overwrite any .htaccess with the content you've placed into it for that account. If you wanted to get really fancy, you could have a file of users in maintenance that is used for the cron script so that you don't have to manually figure out and revise each user. That way you could just edit /root/maintenanceusers or something each time someone is added or removed.

    For the copy of the .htaccess, you could have the .htaccess stored somewhere else on the server as a backup copy in that instance for the cron script to pull the contents.
     
Loading...

Share This Page