大网数据广告活动
网站运营与故障问答

Subdomain folder content returns 404, but root level works

· 52CE 我爱测

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…

问题原文

原帖链接 · 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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2021-09-15)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。