この記事を書いた動機
httpd で公開している Web サイトのドキュメントルートに、icons というフォルダーを配置し、画像を扱おうとするとうまくいかないことがある。httpd デフォルトでは、事前に設定され用意された icons の方を参照してしまい、タブのアイコンや、画像とかが正しく表示されない。それで、二回も同じことにぶつかったというのもあり、メモを取ろうと思った次第。
イメージ
設定前の様子

設定後の様子

httpd の設定
iconsのaliasは以下のようになっている。
/etc/httpd/conf/extra/httpd-autoindex.conf
...
Alias /icons/ "/usr/share/httpd/icons/"
<Directory "/usr/share/httpd/icons">
Options Indexes MultiViews
AllowOverride None
Require all granted
</Directory>
...
この alias を無効化するには、以下のように設定をコメントアウトして、httpd-autoindex.conf を読み込まないようにするだけで良い。
/etc/httpd/conf/httpd.conf
...
# 変更前
# Fancy directory listings
Include conf/extra/httpd-autoindex.conf
...
# 変更後
# Fancy directory listings
# Include conf/extra/httpd-autoindex.conf
...
参考にしたサイト
- How to disable the indexing of the ‘icons’ directory in your Apache HTTP Server | Our Code World
https://ourcodeworld.com/articles/read/1437/how-to-disable-the-indexing-of-the-icons-directory-in-your-apache-http-server (2025年1月29日) - linux - How do I remove the Apache “/icons/” and “/icons/small/” folder alias? - Super User
https://superuser.com/questions/1713548/how-do-i-remove-the-apache-icons-and-icons-small-folder-alias (2025年1月29日)