NextGEN Gallery causing Page Not Found error and Duplicate content pages

I started using Nextgen Gallery [ngg] longtime back. Its a wonderful plugin and very easy to use.

Sometime back, ngg started showing seo friendly urls.

ie, Urls in this format – www.bikes4sale.in/wp/1272/yamaha-ybr-wallpapers/nggallery/image/yamaha-ybr-2/

But something screwed up in their code.

After some days i noticed more than 10,000 page not found errors in Google Webmasters.

There were pages with urls like
www.bikes4sale.in/wp/page/71/?nggpage=vujjjqwofeiqevsp
and
www.bikes4sale.in/wp/page/49/?album=qbiwjwwgeqcofh&pid=265&pageid=605

And the images in galleries in that page had urls like
www.bikes4sale.in/wp/1272/yamaha-ybr-wallpapers/nggallery/image/yamaha-ybr-2/page-vujjjqwofeiqevsp
and these urls were returning page not found error.

Solution for the problem
So i came up with this solution.

1. Tell google to ignore pages with url parameters nggpage and album.
Go to Google Webmasters -> Site configuration -> Url parameters

2. Open nggfunctions.php in nextgen plugin directory.

a. Go to the lines containing $nggpage = get_query_var(‘nggpage’);
Add the following line below those lines.
if(!empty( $nggpage ) && !is_numeric($nggpage)) $nggpage = null;
This will ignore junk nggpage url parameters.

b. Go to the lines containing $album = get_query_var(‘album’);
Add the following line below those lines.
if(!empty( $album) && !is_numeric($album)) $album= null;
This will ignore junk album url parameters.

3. To block search engines from crawling the huge duplicate pages created by Nextgen gallery, i added the following lines in my robots.txt

User-Agent: *
Allow: /
Disallow: /wp/*?nggpage=
Disallow: /wp/*&nggpage=
Disallow: /wp/*?album=
Disallow: /wp/*&album=
Disallow: /wp/*/page-a
Disallow: /wp/*/page-b
Disallow: /wp/*/page-c
Disallow: /wp/*/page-d
Disallow: /wp/*/page-e
Disallow: /wp/*/page-f
Disallow: /wp/*/page-g
Disallow: /wp/*/page-h
Disallow: /wp/*/page-i
Disallow: /wp/*/page-j
Disallow: /wp/*/page-k
Disallow: /wp/*/page-l
Disallow: /wp/*/page-m
Disallow: /wp/*/page-n
Disallow: /wp/*/page-o
Disallow: /wp/*/page-p
Disallow: /wp/*/page-q
Disallow: /wp/*/page-r
Disallow: /wp/*/page-s
Disallow: /wp/*/page-t
Disallow: /wp/*/page-u
Disallow: /wp/*/page-v
Disallow: /wp/*/page-w
Disallow: /wp/*/page-x
Disallow: /wp/*/page-y
Disallow: /wp/*/page-z
Disallow: /wp/*/wp-admin

Please Note My wordpress is installed under the folder “wp” and hence the robots.txt rule starts with /wp/
Thanks to www.webtlk.com/2008/02/16/avoiding-duplicate-content-a-google-issue/ for the tip.