【问题标题】:Force Desktop Site on Varnish在 Varnish 上强制桌面站点
【发布时间】:2015-01-07 02:51:37
【问题描述】:

我使用 varnish 将移动代理重定向到移动站点:

sub vcl_recv {

if (req.http.user-agent ~ "iP(hone|od)|android|(?i)^samsung|(?i)android|(?i)android 3") {

error 750 "Moved Temporarily";

}

}

sub vcl_error {

if (obj.status == 750) {

set obj.http.Location = "http://m.website.com" + req.url;

set obj.status = 301;

return(deliver);

}
}

顺便说一句,在移动网站上我们有网址:

http://www.website.com/?mredirect=yes

有没有办法强制移动代理到桌面版本?这意味着有 url 将起作用。

谢谢!

【问题讨论】:

    标签: magento varnish varnish-vcl


    【解决方案1】:

    添加一个 cookie(在您的网站中),然后签入 varnish VCL:

    if (req.http.Cookie ~ "redirua=0")  // the cookie for "do not redir by UA"
        {       set req.http.X-RedirUA = 0;
                set req.http.BrowserType = "BrowserTypePC";
                set req.http.SkipUA=1;}
        if (req.http.Cookie ~ "redirua=1")
        {        set req.http.X-RedirUA = 1;}
    

    在您的服务器和vcl_hash 中,您需要检查此标头,然后 UNSET 以了解缓存使用情况。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-10
      • 1970-01-01
      相关资源
      最近更新 更多