Creating a maintenance page (htaccess question)

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?
 
That code should be placed here:

Rich (BB 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.
 
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.

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)
 
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?
 
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 :-)
 
Top Bottom