Disable / ignore / redirect URLs with query strings to reduce blog spam

Igor Sysoev igor at sysoev.ru
Fri Jul 8 14:47:18 MSD 2011


On Jul 8, 2011, at 13:17 , TinyApps.Org wrote:

> Hello all,
> 
> Is it possible to disable / ignore / redirect all URLs
> with any query string? My site doesn't use query strings,
> and is suffering from blog spam links as described by
> these folks:
> 
> How do I remove spam from my blog's Google Blog Search results?
> http://www.google.com/support/forum/p/Webmasters/thread?tid=126184f38f712907&hl=en
> 
> Google has the wrong (somewhat vulgar) URL for my site!
> http://www.google.com/support/forum/p/Webmasters/thread?tid=1e30ee39f9e82b4d&hl=en
> 
> URL/Query String Spam - Poor Man's Referer Spam?
> http://www.dgibson.net/blog/article.cfm/articleid=7/URLQuery-String-Spam---Poor-Mans-Referer-Spam
> 
> This Apache .htaccess example < http://briancray.com/2010/03/18/htaccess-hack-remove-url-query-strings/ >
> removes all query strings like so:
> 
> RewriteEngine On
> RewriteCond %{QUERY_STRING} !="" 
> RewriteRule ^(.*)$ /$1? [R=301,L]
> 
> Can something similar be done in nginx? Also, might it be
> better to simply return a 204 (or some other status code)
> to reduce server load?

server {
    if ($args != '') {
        return  301  $uri;
        # OR
        # rewrite  ^  $uri  permanent; 
    }
    ...


--
Igor Sysoev
http://sysoev.ru/en/




More information about the nginx mailing list