1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Creating a maintenance page (htaccess question)

Discussion in 'XenForo Questions and Support' started by RobParker, May 11, 2012.

  1. RobParker

    RobParker Well-Known Member

    My htaccess file looks like this:

    Code:
    #    Mod_security can interfere with uploading of content such as attachments. If you
    #    cannot attach files, remove the "#" from the lines below.
    #<IfModule mod_security.c>
    #    SecFilterEngine Off
    #    SecFilterScanPOST Off
    #</IfModule>
     
    ErrorDocument 401 default
    ErrorDocument 403 default
    ErrorDocument 404 default
    ErrorDocument 500 default
     
    <IfModule mod_rewrite.c>
        RewriteEngine On
     
        #    If you are having problems with the rewrite rules, remove the "#" from the
        #    line that begins "RewriteBase" below. You will also have to change the path
        #    of the rewrite to reflect the path to your XenForo installation.
        #RewriteBase /xenforo
     
        #    This line may be needed to enable WebDAV editing with PHP as a CGI.
        #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
     
        RewriteCond %{REQUEST_FILENAME} -f [OR]
        RewriteCond %{REQUEST_FILENAME} -l [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^.*$ - [NC,L]
        RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
        RewriteRule ^.*$ index.php [NC,L]
    </IfModule>
    
    I tried following the guide here:http://rimuhosting.com/knowledgebase/creating-a-maintenance-page-for-your-site to add a maintenance page whole MySQL was upgraded on our server but it didn't seem to work.

    This is what I added to the htaccess file:

    Code:
     
    
    RewriteEngine On
     RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
     RewriteCond %{DOCUMENT_ROOT}/maintenance.enable -f
     RewriteCond %{SCRIPT_FILENAME} !maintenance.html
     RewriteRule ^.*$ /maintenance.html [R=503,L]
     ErrorDocument 503 /maintenance.html
    
    
    Any ideas what's wrong with that?
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    That code should be placed here:

    Code:
    #    Mod_security can interfere with uploading of content such as attachments. If you
    #    cannot attach files, remove the "#" from the lines below.
    #<IfModule mod_security.c>
    #    SecFilterEngine Off
    #    SecFilterScanPOST Off
    #</IfModule>
     
    ErrorDocument 401 default
    ErrorDocument 403 default
    ErrorDocument 404 default
    ErrorDocument 500 default
     
    <IfModule mod_rewrite.c>
        RewriteEngine On
     
     RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
     RewriteCond %{DOCUMENT_ROOT}/maintenance.enable -f
     RewriteCond %{SCRIPT_FILENAME} !maintenance.html
     RewriteRule ^.*$ /maintenance.html [R=503,L]
     ErrorDocument 503 /maintenance.html
    
    
        #    If you are having problems with the rewrite rules, remove the "#" from the
        #    line that begins "RewriteBase" below. You will also have to change the path
        #    of the rewrite to reflect the path to your XenForo installation.
        #RewriteBase /xenforo
     
        #    This line may be needed to enable WebDAV editing with PHP as a CGI.
        #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
     
        RewriteCond %{REQUEST_FILENAME} -f [OR]
        RewriteCond %{REQUEST_FILENAME} -l [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^.*$ - [NC,L]
        RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
        RewriteRule ^.*$ index.php [NC,L]
    </IfModule>
    
    Don't place it at the end of the file or it won't work.
     
    RobParker likes this.
  3. RobParker

    RobParker Well-Known Member

  4. RobParker

    RobParker Well-Known Member

    Hmm still didn't work.

    Could this be a cache thing that I need to force?
     
  5. CyclingTribe

    CyclingTribe Well-Known Member

    Have you tried adding it to the Apache virtualhost configuration for the site?
     
  6. RobParker

    RobParker Well-Known Member

  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Make sure maintenance.html and maintenance.enable exist in your web root. If it still doesn't work then I can take a look if you give me FTP access.
     
  8. CyclingTribe

    CyclingTribe Well-Known Member

    Ninja'd - I was just going to ask the same thing as the rewrite condition uses %{DOCUMENT_ROOT} so they need to be in the root for that virtualhost.

    Rob, basically this is the folder you connect to when you first connect with your FTP client - the place where your .htaccess file is and your index.php etc. Make sure you have the maintenance.html and maintenance.enable files in this location too. (y)
     
  9. RobParker

    RobParker Well-Known Member

    Ah ok I understand now.

    Our server is structured something like /hsphere/local/account_name/domain_name/

    It's the domain_name folder that contains the .htaccess, index.php, etc but that's not the location where the ftp client first connects to. Can I change document_root to something explicit? Also is there an easy way to see what it's currently set as?
     
    CyclingTribe likes this.
  10. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Visit admin.php?tools/phpinfo

    Search the page for "DOCUMENT_ROOT".
     
  11. RobParker

    RobParker Well-Known Member

    Cheers

    It seems that the document_root is already set correctly (I've removed the actual values below but it's this structure)

    DOCUMENT_ROOT /hsphere/local/home/<account_name>/<domain_name>

    and <domain_name> is where I put the maintenance.html file.

    I'll have a play around and see, thanks for your help :)
     

Share This Page