Block or redirect index.php

Discussion in 'Search Engine Optimization' started by downloadthenet, Sep 12, 2008.

  1. #1
    I have a joomla site and google has indexed domain.com/ and domain.com/index.php, so duplicate content for the home page. Is the best option to block index.php (not used my content URLs) in robots.txt, or redirect it to domain.com in .htaccess like:

    Redirect 301 /index.php http://domain.com/

    If that will even work. Any suggestions?
     
    downloadthenet, Sep 12, 2008 IP
  2. tacoX

    tacoX Peon

    Messages:
    226
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I suggest redirecting index.php to domain.com/. That worked the best for me :). Good luck!
     
    tacoX, Sep 12, 2008 IP
  3. astup1didiot

    astup1didiot Notable Member

    Messages:
    5,926
    Likes Received:
    270
    Best Answers:
    0
    Trophy Points:
    280
    #3
    You need to use the following rewrite code in your .htaccess to do this properly....
    
    RewriteEngine On
    Options +FollowSymLinks
    RewriteCond %{THE_REQUEST} ^[A-Z]{3, 9}\ /.*index\.php\ HTTP/
    RewriteRule ^(.*)index\.php /$1 [R-301,L]
    
    Code (markup):
    Thats good to go as-is, just copy and paste and yout done. :)
     
    astup1didiot, Sep 12, 2008 IP
  4. downloadthenet

    downloadthenet Active Member

    Messages:
    497
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    78
    #4
    Well, I tried redirecting the way I have above and got endless loop. Then I found this

    RewriteCond %{THE_REQUEST} /index\.php\ HTTP/
    RewriteRule ^index\.php$ / [R=301,L]

    Now all 4 versions of the homepage are redirected to one. Thanks.
     
    downloadthenet, Sep 12, 2008 IP
  5. astup1didiot

    astup1didiot Notable Member

    Messages:
    5,926
    Likes Received:
    270
    Best Answers:
    0
    Trophy Points:
    280
    #5
    Whoops I wrote it wrong, add the (.*) thinking it was a non-www to www lol.
     
    astup1didiot, Sep 12, 2008 IP
  6. poseidon

    poseidon Banned

    Messages:
    4,356
    Likes Received:
    246
    Best Answers:
    0
    Trophy Points:
    0
    #6
    yep, redirection is the best way to do although you can use robots.txt to block index.php too. I am surprised joomla's robots.txt do not come up with this!
     
    poseidon, Sep 12, 2008 IP
    ssandecki likes this.
  7. astup1didiot

    astup1didiot Notable Member

    Messages:
    5,926
    Likes Received:
    270
    Best Answers:
    0
    Trophy Points:
    280
    #7
    I think your better off with the 301 redirect then blocking it via robots.txt :)
     
    astup1didiot, Sep 12, 2008 IP