.haccess commands


What do I add to my .haccess file in the main folder of crys.fanworks.net so when someone trys to navigate a sub-folder without an index.(long normal list of extentions) it shows Crys.Fanworks.Net/missing.phtml


Well if you want to disable directory browsing, you can use:
Options -indexes

(this will give a ‘Forbidden’ rather than ‘Missing’ error)


The DirectoryIndex command gives Apache a list of files to check for. It displays the first one that exists, and only if none of them exist does it generate an index of files.

Something like this would work.

DirectoryIndex index.html index.cgi /missing.phtml

As far as I know, there’s no limit to the number of filenames you can list - but how many different extensions do you actually use?

On some of my websites, I use
DirectoryIndex index.html /index.html
so that if I haven’t an index.html in a subdirectory, it takes them back to the home page without explanation. That’s not necessarily polite, not giving an explanation, but is unauthorized snooping polite? I figure I would notice if the index.html was missing from the root directory, but I could lose a /missing.html file and not realize it for months. Maybe you’d want to have the /missing.phtml followed up by an /index.html, just in case…


Thanks Will. Though I knew how to do that… I specifically wanted the 404 page rather than a 403 so the 403 can have info for getting a username pass for protected areas, without confusing people…


Thanks :slight_smile: Though I only currently use index.phtml, I strongly prefer to keep the entire standard list in the DirectoryIndex command, so I don’t have to change the .haccess file in changing my cms.

[quote]is unauthorized snooping polite


no but assuming all requests for a dir without an index.* isn’t either – there are dirs on my site that due to contraints of the cms don’t have index files (ie no yearly archiving) I wouldn’t call trying to find more info by cutting dirs off the end of the path snooping. (now trying to see all my image files…)
Once I have it set up the missing.phtml will be regenerated every time I rebuild the main site, but I intend to use the Options -indexes as well.


duh! ::hits self over head:: 403 and 401 are two different things…

::Wanders off to fix site::


You can set a default 403 page (although it’s a bit tricky to get this to work properly IIRC)…

I don’t think it’s possible to have a 404 page in the situation you describe since 404 means “missing”, and the directory exists, and thus is not “missing”.

Anyway, sounds like you figured out what you wanted to know.


You do know that .haccess files don’t work at Dreamhost, don’t you? You have to use .htaccess files instead.

I can’t believe how many times I saw “.htaccess” without noticing the missing ‘t’.