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 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2010
    Location
    Enschede, Netherlands
    Posts
    34
    Thanks
    18
    Thanked 0 Times in 0 Posts

    redirect / to /index.php

    Dear friends,

    I want to redirect people to index.php like this
    http://www.electronicspub.com/
    TO
    http://www.electronicspub.com/index.php

    because for some reasons I have a index.html also there.
    ELECTRONICSPUB.COM
    All about electronics and hardware

  • #2
    New Coder
    Join Date
    Mar 2010
    Posts
    27
    Thanks
    0
    Thanked 1 Time in 1 Post
    If you have both index.php and index.html in your root directory and you do not need the index.html you can just remove it. You could temporarily rename it index2.html to test it. It used to be index.html/index.htm were looked for first and then index.php. If only 1 index.whatever is present it will just find that. If both or other forms are present it will most likely look for index.htm/.html first. If you do not need index.html then by all means get rid of it. If you are not sure back up the file first and then try it.
    dolphin tutorials and Resources

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    I also wouldn't write a redirection, but I wouldn't rename the index.html either. The reason why I wouldn't is because if the default is to have a directory listing show up and PHP fails for whatever reason then it will show a directory listing instead of whatever the index.html file is.
    Open your httpd.conf file and search for DirectoryIndex. This should register the load order of each file type if just a directory is requested (the index.php file for example). Alter this to move index.php to the left and index.html somewhere to the right of index.php. Restart your apache, and it should now serve your PHP files instead of html ones.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #4
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Quote Originally Posted by Fou-Lu View Post
    Open your httpd.conf file and search for DirectoryIndex. This should register the load order of each file type if just a directory is requested (the index.php file for example). Alter this to move index.php to the left and index.html somewhere to the right of index.php. Restart your apache, and it should now serve your PHP files instead of html ones.
    You can also define the DirectoryIndex in a htaccess file.
    OracleGuy


  •  

    Posting Permissions

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