Help with downtime .htaccess file

Discussion in 'Apache' started by mhuggins, Jun 25, 2008.

  1. #1
    I'm attempting to create a version of .htaccess for when my site needs any sort of downtime (for database upgrades, etc). Part of want I want is to still allow access to directories, image files, CSS files, favicon, and the blog.

    Additionally, I want to allow access to static pages, which in this case would be anything within "example.com/pages/whatever". "pages" is not a directory on the server; instead, it is parsed by my index.php file, as instructed on the last line of this .htaccess file.

    My problem is that even when accessing "pages/anything_here", I still get redirected to downtime.html, and I can't figure out why. Could someone help fix my code?

    <IfModule mod_rewrite.c>
        RewriteEngine On
        
        # remove www from url
        RewriteCond %{HTTP_HOST} !^example.com$ [NC]
        RewriteRule ^(.*)$ http://example.com/$1 [R,L]
        
        # users not coming from my IP address should be redirected to downtime.html
        # continue to allow access to images, css files, blog, and static pages
        RewriteCond %{REMOTE_ADDR} !^xxx.xxx.xxx.xxx$ [NC]
        [b]RewriteCond %{REQUEST_URI} !^/*downtime.html$|favicon.ico$|css|img|blog|pages[/b]
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ downtime.html [L]
        
        # standard cakephp redirection
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
    </IfModule>
    Code (markup):
     
    mhuggins, Jun 25, 2008 IP
  2. mhuggins

    mhuggins Peon

    Messages:
    39
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    * bump *
     
    mhuggins, Jun 30, 2008 IP