5

My site is written in asp.net using mono and apache under ubuntu LTS.

After debugging most of the problems out I still had problems with my icon folder icons. It was giving me the wrong or no icon. Then I notice /blah gets me my custom 404 page while /icons gets me a directory listing.

Why is /icons/ path hitting a directory instead of using my asp.net code? No other path that I know of (ATM) does that.

Side note: /images/ also exist in the same directory as my icons folder. /images/ does not cause a directory listing either.

masegaloeh
  • 17,978
  • 9
  • 56
  • 104

2 Answers2

8

Apache2 comes out of the box with an alias mod file enabled at this location:

/etc/apache2/mods-available/alias.conf

and this is the content of that file

<IfModule alias_module>
        # Aliases: Add here as many aliases as you need (with no limit). The format is
        # Alias fakename realname
        #
        # Note that if you include a trailing / on fakename then the server will
        # require it to be present in the URL.  So "/icons" isn't aliased in this
        # example, only "/icons/".  If the fakename is slash-terminated, then the
        # realname must also be slash terminated, and if the fakename omits the
        # trailing slash, the realname must also omit it.
        #
        # We include the /icons/ alias for FancyIndexed directory listings.  If
        # you do not use FancyIndexing, you may comment this out.

        Alias /icons/ "/usr/share/apache2/icons/"

        <Directory "/usr/share/apache2/icons">
                Options FollowSymlinks
                AllowOverride None
                Require all granted
        </Directory>

</IfModule>

So you can remove the sym link at

/etc/apache2/mods-enabled/alias.conf

to disable the behavior.

steampowered
  • 593
  • 2
  • 10
  • 24
  • 4
    f apache and my 7 year old question. I'm having a fantastic time with nginx –  May 13 '17 at 00:10
  • Yea, I prefer my newer NodeJS servers. But it doesn't make sense to move legacy apps from Apache to Nginx right now. Apache works. – steampowered May 23 '22 at 19:14
  • WTF... wondered why my icons result in a 404 with a clean fresh install of Debian and Apache. Never imagined that there is such a nasty default!?! – Daniel Bleisteiner Sep 14 '22 at 08:30
3

in your httpd.conf you have something like

Alias /icons /path/to/icon/dir
Mike
  • 21,910
  • 7
  • 55
  • 79