Problem with htaccess rewrite and using an html page with stylesheets

Discussion in 'Site & Server Administration' started by bigpapa, Dec 6, 2008.

  1. #1
    When my site is undergoing maintenence, I add the following to my htaccess file to redirect visitors to an offline message:

    RewriteEngine On   
    RewriteBase /   
    RewriteCond %{REQUEST_URI} !^/offline\.html$   
    RewriteRule ^(.*)$ http://www.mydomain.com/offline.html [R=307,L] 
    Code (markup):
    It works fine unless the page uses a stylesheet, even though its located in the same folder as "offline.html".

    If the above rewrite is not added to my htaccess, the html page displays fine with the stylesheet.

    Is it possible to be able to use a stylesheet with such a page?
     
    bigpapa, Dec 6, 2008 IP
  2. tobydawson13

    tobydawson13 Active Member

    Messages:
    645
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #2
    I don't think it is :S

    You could add your css to the offline.html page using the style tags.

    <head>
    <style type="text/css">
    Your CSS here
    </style>
    </head>
    HTML:
     
    tobydawson13, Dec 6, 2008 IP
  3. rony22

    rony22 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    what do you mean of adding this code to your site
    ،،،،
    http://engineering-sciences.blogspot.com
    The new at Engineering
     
    rony22, Dec 6, 2008 IP
  4. zdrol

    zdrol Peon

    Messages:
    19
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    This is because, to the web server, the stylesheet is just another request.

    Try this:

    
    RewriteEngine On   
    RewriteBase /   
    RewriteCond %{REQUEST_URI} !^/(offline\.html|style\.css)$   
    RewriteRule ^(.*)$ http://www.mydomain.com/offline.html [R=307,L] 
    
    Code (markup):
     
    zdrol, Dec 7, 2008 IP