Mobile redirect question

Maikel - Songteksten.nl info at songteksten.nl
Tue Mar 29 14:56:15 CEST 2011


Hi,

I'm using currently the following code to do a mobile site redirect. I
found it somewhere on the internet.

if ( req.http.user-agent ~
"(.*Android.*|.*Blackberry.*|.*BlackBerry.*|.*Blazer.*|.*Ericsson.*|.*htc.*|.*Huawei.*|.*iPhone.*|.*iPod.*|.*MobilePhone.*|.*Motorola.*|.*nokia.*|.*Novarra.*|.*O2.*|.*Palm.*|.*Samsung.*|.*Sanyo.*|.*Smartphone.*|.*SonyEricsson.*|.*Symbian.*|.*Toshiba.*|.*Treo.*|.*vodafone.*|.*Xda.*|^Alcatel.*|^Amoi.*|^ASUS.*|^Audiovox.*|^AU-MIC.*|^BenQ.*|^Bird.*|^CDM.*|^DoCoMo.*|^dopod.*|^Fly.*|^Haier.*|^HP.*iPAQ.*|^i-mobile.*|^KDDI.*|^KONKA.*|^KWC.*|^Lenovo.*|^LG.*|^NEWGEN.*|^Panasonic.*|^PANTECH.*|^PG.*|^Philips.*|^portalmmm.*|^PPC.*|^PT.*|^Qtek.*|^Sagem.*|^SCH.*|^SEC.*|^Sendo.*|^SGH.*|^Sharp.*|^SIE.*|^SoftBank.*|^SPH.*|^UTS.*|^Vertu.*|.*Opera.Mobi.*|.*Windows.CE.*|^ZTE.*)"

        && req.http.host ~ "(www.example.nl|www.example.be)"

        ) {

        set req.http.newhost = regsub(req.http.host, "(www)?\.(.*)",
"http://m.\2");
        error 750 req.http.newhost;

The redirect from www.example.nl to m.example.nl works perfectly, only
www.example.nl/page.php?id=1 also redirect to m.example.nl (so withou
the page.php?id=1 part). 

Is it possible to change the redirect so it also includes the rest of
the url?

Thanks,
Maikel




More information about the varnish-misc mailing list