How can I redirect xxxxxx.com/index.html to xxxxxx.com

Discussion in 'Apache' started by bogart, Feb 28, 2008.

  1. #1
    Google starting showing xxxxxx.com/index.html for my site.

    How do I do a 301 redirect to xxxxxx.com ?
     
    bogart, Feb 28, 2008 IP
    GTech and smatts9 like this.
  2. Crux

    Crux Well-Known Member

    Messages:
    704
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    130
  3. bogart

    bogart Notable Member

    Messages:
    10,911
    Likes Received:
    509
    Best Answers:
    0
    Trophy Points:
    235
    #3
    bogart, Feb 28, 2008 IP
  4. Crux

    Crux Well-Known Member

    Messages:
    704
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    130
    #4
    try this PHP code

    <?php
    
    header("Location: http://forums.digitalpoint.com/index.php);
    
    ?>
    Code (markup):
     
    Crux, Feb 28, 2008 IP
  5. bogart

    bogart Notable Member

    Messages:
    10,911
    Likes Received:
    509
    Best Answers:
    0
    Trophy Points:
    235
    #5
    I need the code to do a 301 redirect to put in my .htaccess file
     
    bogart, Feb 28, 2008 IP
  6. Crux

    Crux Well-Known Member

    Messages:
    704
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    130
    #6

    you are missing a parameter there
     
    Crux, Feb 29, 2008 IP
    bogart likes this.
  7. bogart

    bogart Notable Member

    Messages:
    10,911
    Likes Received:
    509
    Best Answers:
    0
    Trophy Points:
    235
    #7
    This is working for me.

    Redirect requests for domain with index.html to www.

    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/
    RewriteRule ^index\.html$ [url]http://www.example.com/[/url] [R=301,L]
    Code (markup):
    Wondering if anyone has a more simplified code. My hosting was giving a 403 error. When i got the site back on line, Google was indexing xxx.com/index.html

    That put me in an infinite loop
     
    bogart, Feb 29, 2008 IP
  8. kane584

    kane584 Banned

    Messages:
    180
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Hi
    the simplest way to to do this is the following code. My website (nexwiki.org) uses it.

    Edit it in the htaccess.

    
    redirect http://xxx.com/whatever http://www.yyy.xom/whatever
    
    
    
    Code (markup):
    hope it helps
     
    kane584, Feb 29, 2008 IP
    bogart likes this.
  9. bogart

    bogart Notable Member

    Messages:
    10,911
    Likes Received:
    509
    Best Answers:
    0
    Trophy Points:
    235
    #9
    Wasn't working because I'm using mod-rewrite

    You should be using 301 in your code, so that Google sees it as a permanent redirection

    
    redirect 301 http://xxx.com/whatever http://www.yyy.xom/whatever
    
    Code (markup):
     
    bogart, Feb 29, 2008 IP
  10. kane584

    kane584 Banned

    Messages:
    180
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #10
    whats the difference though?
     
    kane584, Feb 29, 2008 IP
  11. bogart

    bogart Notable Member

    Messages:
    10,911
    Likes Received:
    509
    Best Answers:
    0
    Trophy Points:
    235
    #11
    301 redirect is the best way to handle a permanent redirection

    1) 301 redirect permanently redirects the URL
    2) 302 redirect is temporary and may confuse search engines

    Use this tool http://www.seologic.com/webmaster-tools/url-redirect.php to check that your redirection is working correctly. You should return

    HTTP/1.1 301 Moved Permanently
     
    bogart, Feb 29, 2008 IP
    kane584 likes this.
  12. kane584

    kane584 Banned

    Messages:
    180
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #12
    sweet thanks for the tip
     
    kane584, Mar 6, 2008 IP
  13. aap

    aap Well-Known Member

    Messages:
    1,802
    Likes Received:
    39
    Best Answers:
    2
    Trophy Points:
    120
    #13
    You can do this from cpanel redirect option also.
     
    aap, Mar 6, 2008 IP
    bogart likes this.
  14. bogart

    bogart Notable Member

    Messages:
    10,911
    Likes Received:
    509
    Best Answers:
    0
    Trophy Points:
    235
    #14
    The cpanel redirect option is limited

    mod-rewrite is the way to go
     
    bogart, Mar 8, 2008 IP
    chandan123 likes this.
  15. chandan123

    chandan123 Prominent Member

    Messages:
    11,586
    Likes Received:
    578
    Best Answers:
    0
    Trophy Points:
    360
    #15
    i was thinking abt meta tag until i read the whole thread :p
     
    chandan123, Mar 8, 2008 IP
    bogart likes this.
  16. kulinar

    kulinar Member

    Messages:
    45
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #16
    Check my article about avoiding duplicate content on index page. Just replace index.php with index.html
     
    kulinar, Mar 10, 2008 IP
    bogart likes this.
  17. bogart

    bogart Notable Member

    Messages:
    10,911
    Likes Received:
    509
    Best Answers:
    0
    Trophy Points:
    235
    #17
    bogart, Mar 12, 2008 IP