Apache2 和 /icons 路径的行为不同

6 ubuntu mono apache-2.2

我的网站是在 ubuntu LTS 下使用 mono 和 apache 用 asp.net 编写的。

调试完大部分问题后,我的图标文件夹仍然存在问题icons。它给了我错误的图标或没有图标。然后我注意到/blah我得到了我的自定义 404 页面,同时/icons得到了一个目录列表。

为什么/icons/路径命中目录而不是使用我的 asp.net 代码?据我所知,没有其他路径(ATM)可以做到这一点。

旁注:/images/也存在于我的图标文件夹的同一目录中。/images/也不会导致目录列表。

ste*_*red 11

Apache2 开箱即用,在此位置启用了别名 mod 文件:

/etc/apache2/mods-available/alias.conf
Run Code Online (Sandbox Code Playgroud)

这是该文件的内容

<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>
Run Code Online (Sandbox Code Playgroud)

所以你可以删除符号链接

/etc/apache2/mods-enabled/alias.conf
Run Code Online (Sandbox Code Playgroud)

禁用该行为。

  • f apache 和我 7 年前的问题。我在 nginx 中度过了一段美好的时光 (4认同)

Mik*_*ike 3

在你的 httpd.conf 你有类似的东西

Alias /icons /path/to/icon/dir
Run Code Online (Sandbox Code Playgroud)

  • 它位于“/etc/apache2/mods-enabled/alias.conf”中 (2认同)