问题原文
原帖链接 · Yasser · CC BY-SA 4.0
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?
已采纳解答
原帖链接 · Stephen Ostermiller · CC BY-SA 4.0
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.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
