[root@rhce-ryanrudolf]# rm -rf / 2> /dev/null

things I break/fix for fun and learning

Nov 29, 2017 - 1 minute read - Comments

Directory Listing

I just noticed that I can do directory listing on my site, and it will happily list the contents of the directory without warnings or errors. See screenshot below -

before

I don’t want that for several reasons. Instead what I want is a custom error message to be displayed whenever people try to do a directory listing of the site.

Quick fix is to use the custom 404.html from the theme I’m using, but instead rename it as index.html and drop it over to every directory of my site. Here is how it looks now -

after

I’m gonna whip up a script that automates this whenever I regenerate the site.

Went the extra step, reconfigured webserver to use custom 404 message whenever a page does not exist. Edited the following file -

/etc/httpd/conf/httpd.conf

and added this item under the ErrorDocument section -

ErrorDocument 404 /404.html

It now have a universal look whenever someone tries to do a directory listing or whenever a 404 page not found is encountered -

custom404

Like this page? Share it!

Linux CLI and vi cheatsheet Google Analytics

comments powered by Disqus