gpt4 book ai didi

apache - Varnish 4 透明地重写 URL

转载 作者:行者123 更新时间:2023-12-03 17:44:55 24 4
gpt4 key购买 nike

我正在管理一个网站,该网站目前正在运行一个非常标准的 varnish/apache 设置。客户需要添加一个从路径/查询字符串透明地提供服务的新域,以便创建其站点的轻量级版本。例如:

用户访问 mobile.example.com 指向与 example.com 相同的服务器

Varnish 将 mobile.example.com 请求重写为 example.com/mobile?theme=mobile

用户收到由 apache 从 example.com/mobile?theme=mobile 提供的页面,但停留在 mobile.example.com

我们需要点击路径并在此处添加查询字符串,并维护用户输入的任何路径,即:mobile.example.com/test 应该提供 example.com/mobile/test 的内容吗?主题=手机

使用 Varnish 4 执行此操作有什么技巧吗?可能吗?

最佳答案

成功了!

if (req.http.host ~ "^mobile\.example\.com") {
set req.http.host = "example.com";
set req.url = regsub(req.url, "^/", "/mobile/");
set req.url = regsub(req.url, "$", "?theme=mobile");
}

关于apache - Varnish 4 透明地重写 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36837893/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com