Fel*_*lix 2 apache .htaccess varnish varnish-vcl varnish-4
我正在管理一个网站,该网站目前正在运行一个非常标准的 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?theme=mobile 提供内容
使用 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");
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1561 次 |
| 最近记录: |