在 caddy 中为单个文件别名?

问题描述 投票:0回答:1

我想提供一个简单的文件夹作为网站,然后在子文件夹中,我想从另一个根位置提供一些特定的文件(不是整个文件夹,只是一些文件)。

可悲的是,这不起作用:

localhost {
    header {
        Cache-Control "no-cache, no-store, must-revalidate"
    }

    tls C:\localhost\keys\localhost.crt C:\localhost\keys\localhost.key
    log {
        output file C:\localhost\logs\access.log
        format console
    }

    handle_path /js/main.js {
        # THIS DOES NOT WORK
        root "C:\someOtherFolder\main.js"
    }

    handle {
        # handle base www folder
        file_server browse
        root * "C:\localhost\www"
    }
}

我希望文件 https://localhost/js/main.js 提供位于 C:\someOtherFolder\main.js 中的文件,而子文件夹 /js/ 的其余部分则提供其中的任何内容C:\localhost\www\js.

在 apache 中,我会使用带有别名的单行,如下所示:

Alias /js/main.js C:/someOtherFolder/main.js

这怎么办?

alias caddyfile
1个回答
0
投票

您还需要指定它应该由

file_server
处理:

handle_path /js/main.js {
    root "C:\someOtherFolder\main.js"
    file_server
}
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.