0
我用清漆3.设置为通过清漆一个cookie
运行一个Drupal 7个网站,我们有2点:正规网站(example.com)和手机网站(m.example.com)
目前的流程是,当用户通过他的移动设备键入常规站点时,他将直接重定向到移动站点。
我们希望让用户可以通过他的移动设备查看常规站点。
长话短说: 我们如何通过清漆设置cookie(它的重要性在于清漆会设置它,而不是应用程序)。
我们尝试这种代码:
sub_vcl{
if (req.http.host ~ "^example\.com") {
if (req.url ~ "^/(admissions|arts|aspaka|bog|cc|chemistry|GermanHistory|humanities|institutes|lifesci|peace|public-affairs)($|/)|~") {
set req.backend = mondrian;
set req.http.host = "exmpale.com";
}
else {
if (req.http.cookie !~ "nomobi=true") {
if (req.url ~ "nomobi=true") {
set req.http.cookie = "nomobi=true";
}
else {
call devicedetect;
if (req.http.X-UA-Device ~ "^mobile" && req.url !~ "^/registration") {
set req.http.location = "http://m.example.com" + req.url;
error 750 ;
}
}
}
}
}
}
,但它不工作。 谢谢!
凡在此代码触发“设置的cookie”的条件是否合理? (例如,我们希望在请求url时设置它:“http://example.com/?nombi=true”) – doron
您将它添加到粘贴的代码上的'sub_vcl'上。你甚至可以在Varnish上进行设备检测,但我认为它不在这个问题的范围之内 – NITEMAN