Page 1 of 1

Apache + .htaccess Gotcha

Posted: Fri Sep 09, 2011 2:47 pm
by rickyboy
Hello all,

This is just a little tidbit, but it got me. (Gotcha!) I set up Dragonfly locally on my Mac, fired up Apache -- and after that QUERY_STRING problem was resolved (see Help on first time Dragonfly install) -- I could get the start page OK. However, when I tried to access other pages, I kept getting 404s.

I put some garbage in the .htaccess file, expecting to get a 500. Nothin' doin' -- still got the 404. Ah, the .htaccess file is not being read. Why? Because the server's config file (httpd.conf) had an AllowOverride None for the DocumentRoot. I then added the following to httpd.conf.

Code: Select all

<Directory "/document_root/of/your/dragonfly/site">
    Options +ExecCGI
    AddHandler cgi-script .cgi
    AllowOverride Options Limit FileInfo
    Order allow,deny
    Allow from all
</Directory>
Change /document_root/of/your/dragonfly/site accordingly. It works now with this change, even though there may be some unnecessary directives there. The main deal maker here is the AllowOverride Options Limit FileInfo line. One could also put AllowOverride All, but it's a little overkill.

Aside: If you are in a situation where Apache is setup not to allow overrides (i.e. it will not regard your .htaccess file) and you cannot change Apache's httpd.conf (because you don't have admin access, as in a web hosting environment), you need to tell your admin to allow Apache to read your .htaccess file by adding the AllowOverride Options Limit FileInfo directive for your web docs path or virtual host. If they won't do it, you're hosed from running such as Dragonfly there and you should find another provider (because this is a common allowance anymore).

Thanks to the Dragonfly guys for coding the .htaccess file for us. (I love and hate mod_rewrite!) The URLs look great.