Noindex Pager URLs in Drupal 7

  • Published by steve on 8 February 2017.

I required a way to noindex search results in Drupal 7 using Apache Solr but this method should work for any pager views where you want the additional pages to have the noindex tag so Google doesn't index each page. Again, this makes the most sense when dealing with search results because they could be potentially infinite. The end result is that the first page of results would be indexed but additional pages would not be.

In my case I was using an Adaptive Themes sub theme so I added the following code to the <head> section of the html.tpl.php template.
<meta name="robots" content="<?php if (isset($_GET['page'])): ?>noindex,follow<?php else: ?>index,follow<?php endif;?>" />