Search code examples
apache.htaccessdirectoryindex

typing DirectoryIndex into .htaccess and it doesn't work?


This is so frustrating. My root directory is at home/websitename/websitename/ and my httpd.conf has nothing in it!

My .htaccess is in the same directory as the index.php is supposed to be and all I'm typing into .htaccess (and FTP identifies this as an HTACCESS file) is: DirectoryIndex Home.php

The error message I get when trying to visit the site is a 403 forbidden to list the directories of "/"

the AllowOverride directive is set to All


Solution

  • Ok actually I made a dumb mistake. Basically all the things one needs to check in order for the .htaccess to work are these:

    • Create a .htaccess file in the main directory. Make sure the .htaccess file is made in a file editor for ACSII. (notepad++, dev editor, NO Microsoft Word)
    • Make sure AllowOverride is set to All in the Apache configuration for your website. It should be under <directory>
    • Make sure to restart apache after making any changes to the Apache file!! Note that even though .htaccess does not require you to restart Apache, changing anything in the website configuration file requires you to restart Apache in order for it to function.

    Lastly, your website should output a 500 Internal Apache Error if it is able to actually read the .htaccess file, NOT a 403: Access Forbidden or directory listing.