Is it possible: www.site.com/index.php to www.site.com

Discussion in 'Site & Server Administration' started by slava75, May 16, 2006.

  1. #1
    slava75, May 16, 2006 IP
  2. pwaring

    pwaring Well-Known Member

    Messages:
    846
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    135
    #2
    The variable $_SERVER['REQUEST_URI'] contains the URL used to request the current page, so you could check that at the top of your PHP script (before any output is sent) like so:

    if ( $_SERVER['REQUEST_URI'] == '/index.php' )
    {
    header('Location: http://www.site.com/');
    exit;
    }
    PHP:
    I think that's right, but I haven't tested the code. :)
     
    pwaring, May 16, 2006 IP
  3. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Or, using htaccess:
    RewriteEngine on
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php3\ HTTP/ 
    RewriteRule ^index\.php3$ http://www.domain.co.uk [R=301,L] 
    Code (markup):
     
    mad4, May 16, 2006 IP
  4. slava75

    slava75 Well-Known Member

    Messages:
    205
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    168
    #4
    Thank you. Will give a try.
     
    slava75, May 16, 2006 IP