【问题标题】:how to setup lighttpd for subdirectory mappings?如何为子目录映射设置 lighttpd?
【发布时间】:2023-08-01 09:03:01
【问题描述】:

对于相同的主机名,我想做如下映射

/subdirectory/_different_end_points_.json map to 127.0.0.1:9001

/_different_end_points_.json map to 127.0.0.1:9002

如何做到这一点?根据文档,要求 else 子句也必须匹配一个条件,这让我抓狂(作为正则表达式的初学者)

【问题讨论】:

    标签: installation lighttpd subdirectory


    【解决方案1】:

    你有没有尝试过这样的事情:

    $HTTP["url"] =~ "^/subdirectory/_different_end_points_.json" {
      proxy.server = (
        "/" => (("host" => "127.0.0.1", "port" => 9001))
      )
    }
    else $HTTP["url"] =~ "^/_different_end_points_.json" {
      proxy.server = (
        "/" => (("host" => "127.0.0.1", "port" => 9002))
      )
    }
    

    这样,您将开始的每个网址与/subdirectory/_different_end_points_.jso 或(在其他)/_different_end_points_.json 匹配。

    但请确保您的网址确实以正则表达式开头!我的意思是:h*tp://sample.com/subdirectory/_different_end_points_.json 和 h*tp://sample.com/_different_end_points_.json

    【讨论】: