Is Index file necessary in each website?

Discussion in 'PHP' started by ankushsinghal, May 20, 2011.

  1. #1
    Is Index file necessary in each website? If yes, then how we can hide it from the from the web searcher?
     
    ankushsinghal, May 20, 2011 IP
  2. KastorPM

    KastorPM Peon

    Messages:
    11
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Create robots.txt in your site root directory

    robots.txt:
    User-agent: *
    Disallow: /
     
    KastorPM, May 20, 2011 IP
  3. etc

    etc Well-Known Member

    Messages:
    3,239
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    158
    #3
    why hide it?
    i don't get why you would hide the index when its your homepage.
     
    etc, May 20, 2011 IP
  4. ankushsinghal

    ankushsinghal Peon

    Messages:
    38
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    But i think robots.txt used for the crawler and not for the user point of view.
    How we can hide index file from user with robots.txt
     
    ankushsinghal, May 20, 2011 IP
  5. KastorPM

    KastorPM Peon

    Messages:
    11
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    For users - .htaccess

    Order Allow,Deny
    Deny From All
     
    KastorPM, May 20, 2011 IP
  6. ankushsinghal

    ankushsinghal Peon

    Messages:
    38
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I don't want to remove my home page. I try to tell my question with an example.
    Suppose a website open with 'abc.com' and its also open with 'abc.com/index.php' so now what can i do so the user not able to open /index.php and crawler also treated that index file as 'abc.com' and not consider it as the different page with duplicate content.
     
    ankushsinghal, May 20, 2011 IP
  7. ssmm987

    ssmm987 Member

    Messages:
    180
    Likes Received:
    4
    Best Answers:
    3
    Trophy Points:
    43
    #7
    
    Redirect 301 /index.php /
    
    Code (markup):
    Or add this in your index.php:
    
    if($_SERVER['REQUEST_URI']=='/index.php')header('Location: /');
    
    PHP:
     
    ssmm987, May 20, 2011 IP
  8. ankushsinghal

    ankushsinghal Peon

    Messages:
    38
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Thanks a lot..
     
    ankushsinghal, May 22, 2011 IP