Doesn't like index.php as main page

Discussion in 'PHP' started by RogerInHawaii, Jun 11, 2007.

  1. #1
    I've built a website and some of the pages are php pages (e.g. SomePage.php). It all works fine; both the html pages and the php pages come up and work just fine.

    I then made a change to the main index.html file and made it so that it's an index.php file instead, and it has some php code embedded in it, not much different than any of the other php pages on my site.

    But when I try to go to that index.php file, as the first file to bring up for the site, it fails to bring up the page but instead pops up an Open File dialog, asking if I want to Open or Save the index.php file. It's as if the server is not recognizing index.php as being a php file that needs the normal php pre-processing on the server side. I used to get similar prpoblems with the other php pages before I had my server properly set up with Apache and php and such. But all of that is indeed properly set up. The OTHER php pages come up OK. It's just the very first, index.php page, that doesn't come up correctly.

    What am I doing wrong?

    Is there a standard way for making it bring up the first page as a php file?
     
    RogerInHawaii, Jun 11, 2007 IP
  2. pdsllc

    pdsllc Well-Known Member

    Messages:
    180
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    105
    #2
    If you have access to your .htaccess file add this line to the file

    DirectoryIndex index.php index.htm index.html

    The server searches for index.php, then index.htm, then index.html in that order.

    If not, have your host change it.
     
    pdsllc, Jun 11, 2007 IP
  3. RogerInHawaii

    RogerInHawaii Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Right now I'm running this strictly locally on my own develoment machine, during the site debugging process. Where might I find that .htaccess file on my machine?
     
    RogerInHawaii, Jun 11, 2007 IP
  4. Hobbit2

    Hobbit2 Active Member

    Messages:
    720
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    60
    #4
    I believe you have to make it, and place it in your root directory.
     
    Hobbit2, Jun 11, 2007 IP
  5. demonhale

    demonhale Peon

    Messages:
    352
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yes you need to make it, you can make it via a regular text editor and upload via ftp. Then you can rename it .htaccess if the file dont already exist on your root folder...
     
    demonhale, Jun 11, 2007 IP
  6. coderbari

    coderbari Well-Known Member

    Messages:
    3,168
    Likes Received:
    193
    Best Answers:
    0
    Trophy Points:
    135
    #6
    You just open a text file in textpad and write the rule and save it as renaming .htaccess.your .htaccess is ready.now place it in the folder for which you want to apply the rules.
     
    coderbari, Jun 12, 2007 IP