Redirecting from site.com to site.com/index.html

Discussion in 'Site & Server Administration' started by dper, Jun 9, 2007.

  1. #1
    I have PHP & Ajax code that doesn't work unless the visitor is on index.html.
    It doesn't matter if it is http:// www or http://www

    How can I redirect visitors from site.com or www .site.com etc.. to index.html?
     
    dper, Jun 9, 2007 IP
  2. bouncer69

    bouncer69 Peon

    Messages:
    978
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It will solve your problem.


    Options +FollowSymLinks
    
    <IfModule mod_rewrite.c>
    
    RewriteEngine On
    RewriteCond %{HTTP_HOST} . 
    RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC] 
    RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
    RedirectMatch permanent ^/$ http://www.domain.com/index.html
    </IfModule>
    Code (markup):
     
    bouncer69, Jun 10, 2007 IP
  3. inworx

    inworx Peon

    Messages:
    4,860
    Likes Received:
    201
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If I am not wrong, isnt index.htm or index.html opened up by default if no page is entered?
     
    inworx, Jun 11, 2007 IP
  4. bouncer69

    bouncer69 Peon

    Messages:
    978
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #4
    If index.htm and index.php in the same directory most of the server execute index.php not index.htm but if it is index.html it will open before index.php.
     
    bouncer69, Jun 11, 2007 IP
  5. cyanide

    cyanide Peon

    Messages:
    483
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    0
    #5
    If you're on Apache, you can force index.html to be the default home page if it isn't already.
    Put the following in an htaccess file
     
    cyanide, Jun 11, 2007 IP