Dealing with apache quirks

Table of Contents

Apache Nightmare

So I have spent the last several hours pulling hair out trying to figure out why my favicons refused to load on the server but worked fine on localhost. Well come to find out thanks to a 14 year old forum thread I figured it out. And WTF apache? really? What was the issue you ask?

Apache has something called alias.conf and why is it a problem? Well if you are like a lot of people you will put favicons and other icons into

/icons

folder on your web root. well that is a problem….

Why?

Cause in the alias.conf it has this line

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

What does it do? Any request for URL/icons/filename will get directed to

/usr/share/apache2/icons/

Which of course gives a 404 not found along with a 403.

So if you happen to be having this issue with your icons not showing up on your server but working on localhost then go into (in debian, other os may have a different path)

/etc/apache2/mods-available/

open the file

alias.conf

  • You should know how to edit files on linux but if you don’t the command nano alias.conf or vim alias.conf will open the file in a cli text editor

find the line

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

change it to

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

then restart apache systemctl restart apache2

And your icons in /icons/ should start showing up instead of giving 404/403 errors.

edited 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>