Throwing out 404 on index.html with htaccess?

Discussion in 'Site & Server Administration' started by Knuttenstein, Jul 23, 2009.

  1. #1
    I would like to know if its possible to throw out a 404 for a specific page, specifically the index page to avoid duplicate content. Currently im doing it in PHP like below.

    if ($_SERVER['REQUEST_URI'] == '/index.php') {
      header('HTTP/1.1 404 Not Found');
      include_once '404.php';
      exit();
    }
    Code (markup):
    And thats fine, but i would just like to know if its possible in htaccess as well. Anyone?
     
    Knuttenstein, Jul 23, 2009 IP
  2. SecureCP

    SecureCP Guest

    Messages:
    226
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    sure there is

    
    Redirect /index.htm  http://www.yoursite.com/404.html
    Code (markup):
     
    SecureCP, Jul 23, 2009 IP
  3. Janak

    Janak Peon

    Messages:
    68
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You just need to enter the code in .htaccess file provided by secureCP.

    That's it!!
     
    Janak, Jul 24, 2009 IP
  4. SecureCP

    SecureCP Guest

    Messages:
    226
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Gotta love that .htaccess file! So flexible.
     
    SecureCP, Jul 24, 2009 IP