Apache setting question

Posted:
in macOS edited January 2014
How do I change the Apache settings ?



I want it to recognize .php files by default. As it is now, having a file called index.php and calling the directory its in, makes it give me an index of... page..



.:BoeManE:.

Comments

  • Reply 1 of 4
    ibrowseibrowse Posts: 1,749member
    In the folder etc/httpd/ there is a file called httpd.conf. This is the configuration for Apache. You need to find a section that should look like this

    Code:


    #

    # DirectoryIndex: Name of the file or files to use as a pre-written HTML

    # directory index. Separate multiple entries with spaces.

    #

    <IfModule mod_dir.c>

    DirectoryIndex index.html

    </IfModule>









    You need to add one for PHP, but whether it is supposed to look like



    Code:


    #

    # DirectoryIndex: Name of the file or files to use as a pre-written HTML

    # directory index. Separate multiple entries with spaces.

    #

    <IfModule mod_dir.c>

    DirectoryIndex index.html index.php

    </IfModule>









    Or



    Code:


    #

    # DirectoryIndex: Name of the file or files to use as a pre-written HTML

    # directory index. Separate multiple entries with spaces.

    #

    <IfModule mod_dir.c>

    DirectoryIndex index.html

    </IfModule>



    <IfModule mod_dir.c>

    DirectoryIndex index.php

    </IfModule>









    I don't remember. I know that it is fine to have both in there, because I used to and it worked fine.
  • Reply 2 of 4
    ibrowseibrowse Posts: 1,749member
    The second way will work fine.
  • Reply 3 of 4
    eugeneeugene Posts: 8,254member
    Well, the first way is the most practical/popular way to do it.
  • Reply 4 of 4
    torifiletorifile Posts: 4,024member
    I do it the first way, too. I think that the order of the arguments is important. So if you have an index.html and index.php files in the same directory, it'll default to whatever is listed first. I always put my index.php argument first because it's less likely to there "by accident."
Sign In or Register to comment.