私は現在、一般的なキャッシュなどのために Varnish をセットアップしていますが、当社の Web サイトのモバイル バージョンのリダイレクトとしても機能しています。
これは (Varnish のように) うまく機能し、意図したとおりにリダイレクトします。モバイルをサイトのモバイル バージョンにリダイレクトするだけでなく、モバイル サイト (Google など) へのリンクにアクセスしているデスクトップをデスクトップ バージョンのサイトにリダイレクトする機能を VCL 構成に追加することにしました。
ただし、これを最も不可解な方法で機能させることはできないようです。VCL は次のとおりです。
# 特定の共有アセットを無視 if (req.url !~ ".(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|css)$") {
# Let's detect if we're a Mobile
if (req.http.User-Agent ~ "iP(hone|od)" || req.http.User-Agent ~ "Android" || req.http.User-Agent ~ "Symbian" || req.http.User-Agent ~ "^BlackBerry" || req.http.User-Agent ~ "^SonyEricsson" || req.http.User-Agent ~ "^Nokia" || req.http.User-Agent ~ "^SAMSUNG" || req.http.User-Agent ~ "^LG" || req.http.User-Agent ~ "webOS" || req.http.User-Agent ~ "^PalmSource") {
# If we're a mobile, set the X-Device header.
set req.http.X-Device = "mobile";
# If we've not set a preference to the fullsite to override the redirect, and we're not accessing the mobile site, redirect. This all works fine.
if ((req.http.Cookie !~ "fullsite")&&(req.url !~ "mobile")){
error 750 "Moved Temporarily";
}
}
else{
# We're not mobile. I can see this header is set in the logs.
set req.http.X-Device = "desktop";
# If we're a desktop AND accessing the mobile site....
if (req.url ~ "mobile"){
# -------------------- THIS NEVER HAPPENS
error 750 "Moved Temporarily";
}
}
}
ここのロジックに明らかなエラーがありますか? 私が見ることができるリダイレクトを妨げる可能性のあるCookieやその他のものはありません。誰かがこれについて何か洞察を持っているなら、私は永遠に感謝します:)よろしくB