Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,127
    Thanks
    27
    Thanked 0 Times in 0 Posts

    Removing index.php

    How do I create a mod_rewrite so that if my website is accessed via....

    http://local.debbie/index.php

    ...then things get rewritten to...

    http://local.debbie


    (While testing my website, my code seems to be working properly, but when I first launch "index.php" I don't want to see it. And, of course, the same behavior should apply when my website is on the Internet.)

    Thanks,


    Debbie

  • #2
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,415
    Thanks
    269
    Thanked 32 Times in 31 Posts
    From my experience index files wether it be .html .htm .php or what have you, are requried by default and the server will look for these files in a certain order from a list of about 26 options.

    Now i have seen empty index.php files in dir before and i am not sure if that is required to do this next step or not.

    But you can specify in your .htaccess file the file name you want to use as your top tier file instead of an index.

    some thing like this in your .htaccess

    Code:
    DirectoryIndex something.html
    Which the server will now look for that file name and will longer look for any other name as the index.

    This was my source as i have not done this before so if you want to refer to this here ya go..

    http://support.tigertech.net/index-file-names

  • #3
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    This can be done:

    Code:
    RewriteCond %{THE_REQUEST} ^.*/index.php 
    RewriteRule ^(.*)index.php$ /$1 [R=301,L]
    This redirects anyone trying to access index.php (in any directory at or above the location of the .htaccess file containing this rule) back to the folder in which the index.php file is meant to be located.

    So this:
    http://www.example.com/some/folder/index.php
    should rewrite to this:
    http://www.example.com/some/folder/

    and this:
    http://www.example.com/index.php
    should rewrite to this:
    http://www.example.com/

    ...and so on.
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •