Removing the index.php

Discussion in 'Apache' started by mark_s, Aug 11, 2006.

  1. #1
    A lot of internal links in my forum that link back to the index go to this url /messageboard/index.php but I would prefer it to appear to go to /messageboard/ without the index.php bit as I want all the PR to go to that (if that makes a difference).

    Can this be done with mod_rewrite?
     
    mark_s, Aug 11, 2006 IP
  2. talentcoder

    talentcoder Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    yes, but not necessary, simply modify DirectoryIndex in your httpd.conf:

    DirectoryIndex index.html index.htm index.php
     
    talentcoder, Aug 11, 2006 IP
  3. mark_s

    mark_s Peon

    Messages:
    497
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I have index.php in the DirectoryIndex already but when people are linking specifically to http://www.xxx.com/messageboard/index.php it still shows up on the address bar that they went to /index.php

    I tried doing
    RewriteEngine on
    RewriteRule ^index.php$ http://www.xxx.com/messageboard/[R=301,L]

    But got an error.
     
    mark_s, Aug 11, 2006 IP
  4. Cryogenius

    Cryogenius Peon

    Messages:
    1,280
    Likes Received:
    118
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Try this instead:
    
    RewriteEngine on
    RewriteRule ^messageboard/index.php$ http://www.xxx.com/messageboard/ [R=301,L]
    
    Code (markup):
    Can't you edit your forum code to not use index.php in it's links? It might be easier to go the other way, i.e. make all links point to index.php, even external ones.

    Cryo.
     
    Cryogenius, Aug 11, 2006 IP
  5. mark_s

    mark_s Peon

    Messages:
    497
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I guess I can but wanted to use mod_rewrite as it would be easier and quicker.

    I just want all my PR to go to /messageboard/ rather than index.php as /messageboard/ will probably be used more in external links.
     
    mark_s, Aug 11, 2006 IP
  6. talentcoder

    talentcoder Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    yes, mod_rewrite can do that. But you can also try this in your index.php
    <?php
    header("location: http://www.xxx.com/messageboard/");
    ?>
    It's even eaiser than using mod_rewrite
     
    talentcoder, Aug 16, 2006 IP