2

I am setting up a subdomain - subdomain.example.com for my existing example.com to serve application with distinct origin

Using DNS manager of my registrar, DNS Manager: type CNAME, name: subdomain, points to @

And in my Apache 2.4 sites-available I have the existing example.com.confand example.com-ssl.conf so I made a new vhost for my subdomain, subdomain.example.com.conf and subdomain.example.com-ssl.conf

<VirtualHost *:80>
        DocumentRoot "/var/www/subdomain/public_html"
        ServerName subdomain.example.com
        <Directory /var/www/subdomain/public_html>
           AllowOverride All
           Order Allow,Deny
           Allow from All
        </Directory>
        LogLevel trace5
        ErrorLog ${APACHE_LOG_DIR}/subdomain-error.log
        CustomLog ${APACHE_LOG_DIR}/subdomain-access.log combined
</VirtualHost>

Server Folders:

/var/www/subdomain/public_html
/var/www/subdomain/public_html/icons

If I browse to subdomain URL, it works fine: http://subdomain.example.com works

Now if I browse to any subdirectory content, it returns 404: http://subdomain.example.com/icons/icon.png

Not Found The requested URL was not found on this server.

subdomain-error.log error: AH00128: File does not exist: /usr/share/apache2/icons/icon.png

What am I doing wrong? Or there is an something else causing this?

11
  • Do you have any Alias directives for /icons anywhere in your Apache configuration? Sep 15, 2021 at 9:48
  • 1
    Are there any errors in other error.log files? Sep 15, 2021 at 15:47
  • I went through the other conf files too, there is no "icons" mentioned in the "sites-available" directory no errors under these settings in the subdomain-error.log file
    – Yasser
    Sep 15, 2021 at 16:36
  • How are you testing that URL? Are you using curl? If you are using your web browser have you cleared the cache? Sep 15, 2021 at 16:45
  • Does the hit to icon.png show up in subdomain-access.log? Sep 15, 2021 at 16:45

1 Answer 1

2

The problem is in a default configuration file that is included with Apache2 from Debian and Ubuntu: /etc/apache2/mods-available/alias.conf which has:

# 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/"

You can comment out that line in the configuration, or delete the sym-link to that configuration file so that Apache doesn't use it: sudo rm -f /etc/apache2/mods-enabled/alias.conf. After making configuration changes, you need to tell Apache to reload all its configuration: sudo service apache2 reload.

Another option is to choose a different directory name for the icons on your own site. You might want to choose a different name, because edited configuration files could get reverted to the original when upgrading Apache.

2
  • Thanks a lot for helping me out. I thought It was a problem in my config or setup
    – Yasser
    Sep 15, 2021 at 20:08
  • 1
    I initially thought it sounded like an Alias problem. I should have had you do a grep -r 'Alias.*icon' /etc/apache2 when I asked if you had any such directives. Sep 15, 2021 at 20:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.