__utm.gif --- how to redirect request?

Joshua Zhu zhuzhaoyuan at gmail.com
Fri Sep 11 09:16:02 MSD 2009


Hi Igor,

Typo? I guess it should be 'rewrite' instead of 'redirect'. :D

2009/9/11 Igor Sysoev <is at rambler-co.ru>:
> On Thu, Sep 10, 2009 at 07:27:39PM -0500, Nick Pearson wrote:
>
>> These requests could be from crawlers.  A couple ways to tell: (1) are
>> the requests from just a few IPs, or from lots of different IPs?  And
>> (2) do the requests contain all the query string parameters that are
>> sent to Google Analytics?
>>
>> I run several sites, all of which use Google Analytics, but I've never
>> seen this particular request in the logs.  I have seen some others of
>> unused assets that crawlers found in various JavaScript or CSS files.
>> Some crawlers seem to scrape all referenced files for something that
>> looks like a URL and then attempt to access it.  I even get requests
>> for "http://tel:/18002345678" from mobile site pages where I have
>> links like <a href="tel:18002345678">1-800-234-5678</a>.  The crawler
>> doesn't understand, but makes the request anyway.
>>
>> I would definitely figure out why this is happening first, but to
>> answer your question, this should do what you need:
>>
>> location ^~ /__utm.gif {
>>     redirect  ^  http://http://www.google-analytics.com$request_uri;
>> }
>
> Small correction:
>
> - location ^~ /__utm.gif {
> -     redirect  ^  http://http://www.google-analytics.com$request_uri;
>
> + location = /__utm.gif {
> +     redirect  ^  http://www.google-analytics.com$request_uri?;
>
>> You'll want to pass the $request_uri, otherwise the request to Google
>> Analytics will be meaningless (because it won't contain any tracking
>> data).
>>
>> By the way, if the traffic is over SSL, be sure to redirect here
>> instead, so as not to cause a security warning in some browsers:
>>
>>     redirect  ^  https://ssl.google-analytics.com$request_uri;
>>
>> Also note that I haven't tested these, but I don't see why they
>> wouldn't work.  However, that being said, I don't know how well
>> browsers respect redirects for image requests.
>>
>>
>> On Thu, Sep 10, 2009 at 6:27 PM, Ilan Berkner <iberkner at gmail.com> wrote:
>> > Hi All,
>> > Simple question, I think.
>> > Our error log is flooded with file not found requests for __utm.gif.  This
>> > is part of google analytics and for some reason, the requested pages (some)
>> > are trying to load it locally.
>> > I have yet to figure this problem out in terms of the "why" but for now, I
>> > want to remove it from my error log.
>> > 2 options:
>> > 1. Put a copy of the file in our root directory which will quiet down the
>> > error log or
>> > 2. Redirect requests to the file via nginx configuration file, something
>> > like this:
>> > location /__utm.gif {
>> >   [ redirect to: http://www.google-analytics.com/__utm.gif]
>> > }
>> > What would be the correct format for above?
>> > Also, has anyone encountered this issue before?
>> > Thanks
>
> --
> Igor Sysoev
> http://sysoev.ru/en/
>
>

Cheers,

-- 
Joshua Zhu
http://www.zhuzhaoyuan.com





More information about the nginx mailing list