Find the answer to your Linux question:
Results 1 to 6 of 6
Hi, I hosted my site on Apache web server. I wanted to redirect all the users request to a HTML page(maintenance page). I used the below rewrite rule to do ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2010
    Posts
    1

    Need help with rewrite rule


    Hi,

    I hosted my site on Apache web server.

    I wanted to redirect all the users request to a HTML page(maintenance page).

    I used the below rewrite rule to do ths same.

    RewriteEngine on
    RewriteRule .* /maintenance.html

    The maintenance.html page contains an image.

    When ever I try to access my site(during maintenance),I am being redirected to the maintenance.html page.But, I am unable to see the image.

    Any help would be grateful.....

    Thanks,
    Srikanth Bodakunta

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,380
    You could create a directory "maintenance"
    and then place maintenance.html and picture in there.

    The Rewrite Rule would then work via negation
    RewriteRule ! ^/maintenance/(.*) /maintenance/maintenance.html

    Also, you might want to add maintenance.html to DirectoryIndex.
    You must always face the curtain with a bow.

  3. #3
    Just Joined!
    Join Date
    Oct 2010
    Posts
    1
    Hi Irithori,

    I have tried using the rewite rule you have suggested.But, it still does not work.

    I actually wanted all requests to be redirected to the maintenace.html,except the image that I have tried using in the maintenace.html.

    Below is the Rewrite rule
    RewriteEngine on
    RewriteRule !^image.jpg /maintenance.html
    RewriteRule .* /maintenance.html

    Thanks,
    Srikanth Bodakunta.

  4. #4
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,380
    That rule doesnt make sense
    RewriteRule !^image.jpg /maintenance.htm

    And my advice requires to have a directory "maintenance" that contains maintenance.html and the image,
    as I have written.


    If you do not want to have the maintenance directory,
    then this might work
    Code:
    RewriteCond %{REQUEST_URI} !^/maintenance.html  [OR]
    RewriteCond %{REQUEST_URI} !^/image.jpg  
    RewrtiteRule ^/.* /maintenance.html
    Last edited by Irithori; 10-07-2010 at 12:41 PM.
    You must always face the curtain with a bow.

  5. #5
    Just Joined!
    Join Date
    Oct 2010
    Posts
    1
    Thanks a lot.....it worked for me.....

  6. #6
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,380
    Which version, if I may ask?
    You must always face the curtain with a bow.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •