How to turn of the website temporarily?

Discussion in 'Site & Server Administration' started by kingofdawn, Dec 3, 2008.

  1. #1
    Hello,

    I have a website based on php/apache with access to .htaccess files.

    I want to turn off the website completely, for instance a user visiting any page would see a default message saying "we are upgrading this page, please come back tomorrow" (i.e. content of /site_down.php). However, this will need to be done in order to upgrade some parts of the website and test it's functionality so I will need to have access to it. At the moment, whenever site is down for some reason I un-comment one line in /.htaccess and all traffic is redirected to /site_down.php. But I dont have access to it either :)

    What would be the easiest solution to make it work so only I have access to it? Hmm, I could probably do a condition in .htaccess saying:

    if DNS = 'dns.provider.com' then allow
    else deny

    (what would be the correct syntax?)

    Or is it better to do it in php? Can someone advise please?
     
    kingofdawn, Dec 3, 2008 IP
  2. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #2
    You can use allow and deny statements.

    Allow from YOUR_IP
    Deny from all

    Note, that might not be the full syntax, it's just a demo. Then, you can do something like:

    ErrorDocument 403 "Sorry, we're upgrading
    Code (markup):
    There is no closing " mark. They will be given the Sorry, we're upgrading message, rather than "403 Forbidden"

    Jay
     
    jayshah, Dec 4, 2008 IP
  3. icecubedesigns

    icecubedesigns Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Just make your home page to view this and then move all the contents to a password protected folder
     
    icecubedesigns, Dec 4, 2008 IP
  4. kingofdawn

    kingofdawn Peon

    Messages:
    85
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    this is not possible with 1000+ files, whole structure of directories and PHP paths in scripts....

    anyway, will play around with it.

    ta.
     
    kingofdawn, Dec 5, 2008 IP
  5. zdrol

    zdrol Peon

    Messages:
    19
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You can use mod_rewrite for this.

    For example:

    
    
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REMOTE_ADDR} !^10\.100\.0\.55$
    RewriteCond %{REMOTE_URI} !^upgrading\.html$
    RewriteRule ^(.*)$ /upgrading.html [L]
    
    
    Code (markup):
    That way, unless you are not coming from 10.100.0.55 AND you are not accessing upgrading.html, all requests will be rewritten (forwarded, if you will) to upgrading.html
     
    zdrol, Dec 7, 2008 IP
  6. kingofdawn

    kingofdawn Peon

    Messages:
    85
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    thanks zdrol

    it works perfectly - the correct syntax though is:

    
        RewriteEngine On
        RewriteBase /
        RewriteCond %{REMOTE_ADDR} !^88\.209\.173\.81$
        RewriteRule ([^/]+) site_offline.html [L]
    
    Code (markup):
    any address requested from that domain will have the content of the "site_offline.html" displayed UNLESS you are coming from the IP address in the rule.

    .htaccess and site_offline.html should be in the root directory

    thanks again.
     
    kingofdawn, Dec 9, 2008 IP
  7. ravee1981

    ravee1981 Active Member

    Messages:
    712
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    60
    #7
    best upload an index.html file with what ever you want your visitors to see. you can access your site thru domainname/index.php
     
    ravee1981, Dec 10, 2008 IP