Redirect everything to /index.html

Discussion in 'Apache' started by CardinalCase, Aug 4, 2009.

  1. #1
    Greetings,

    I have been researching the best way to do this with .htaccess. I have an entire wordpress install in the root directory, and would like to temporarily forward everything to: samewebsite.com/index.html

    index.html is a temporary page, and already comes up automatically before wordpress's index.php. But, Google has indexed some content already and I wish to forward the visitors arriving via deep links to the temporary page.

    Current contents of .htaccess:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    
    Code (markup):


    Thanks,
    - CC
     
    Last edited: Aug 4, 2009
    CardinalCase, Aug 4, 2009 IP
  2. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #2
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.html [L]
    </IfModule>


    Change it to that
     
    Bohra, Aug 5, 2009 IP
  3. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Probably

    RewriteCond %{REQUEST_URI} !/index.html$
    
    RewriteRule $ /index.html [R=302,L] 
    Code (markup):
    (And comment out everything under rewritebase with #) (untested)
     
    premiumscripts, Aug 5, 2009 IP
  4. CardinalCase

    CardinalCase Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I appreciate the responses. I will test them out shortly and let everyone know what worked.

    Thanx
    -cc
     
    CardinalCase, Aug 6, 2009 IP
  5. CardinalCase

    CardinalCase Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Both work in forwarding to website.com/index.html. Thank you both so much.

    The differences . . .

    Will keep any requested URL intact to the viewer, while actually displaying: website.com/index.html's content. (Extra points for sneakiness :cool:)


    Will display the content and forward the URL that is visible to the person to: website.com/index.html.



    I'm even able to use an image from the same site in its index.html. I didn't think that would be possible with the Rewrite.
     
    CardinalCase, Aug 10, 2009 IP
  6. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Yes, these two lines make sure that images and files will still work:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    Code (markup):
    But I would still redirect to index.html though. Probably better for google if it gets a header 302 response instead of a content overwrite.
     
    premiumscripts, Aug 10, 2009 IP
  7. CardinalCase

    CardinalCase Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Hmm, well I checked today and the image in index.html on the same site was not showing, so I simply hosted it elsewhere for the time being.
     
    CardinalCase, Aug 11, 2009 IP
  8. kulinar

    kulinar Member

    Messages:
    45
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #8
    Well, that is not very good idea because thus duplicate content is created (different pages with the same content) and the chance for pages to become supplemental is big.
     
    kulinar, Aug 15, 2009 IP