Automatically fit long file names in Apache directory listing pages
Does anyone still run Apache locally for web development? I do. I know there are other simpler, command line based options but I still like having apache there, always on. Depending on what I'm doing, I use CodeKit, or something else with live reload, or a hot loader but I still like that I can drop a file or directory in a directory apache knows about and it's accessible via localhost. Sure, Apache is almost always guaranteed to break when I do a major OS upgrade but that's a once-a-year annoyance (at most).
Anyway, since I regularly look at apache directory listings, I get annoyed by apache truncating file names. This is what I'm talking about:
And here's the improved version:
To get the latter, improved version, first make sure Apache is loading the autoindex_module
. Check your httpd.conf
to make sure the appropriate LoadModule
line is not commented out:
LoadModule autoindex_module libexec/apache2/mod_autoindex.so
Next, add an <IfModule>
block somewhere that specifies NameWidth=*
like so:
<IfModule autoindex_module>
IndexOptions NameWidth=*
</IfModule>
Restart apache:
apachectl restart
That's it!