I have a view at path "mypath". Without Clean Pagination, the view pages as "mypath?page=3". With Clean Pagination, the view pages as "mypath/page/3", but I can still access the paged version of the view at "mypath?page=3".

This is bad for SEO because the same content appears at two unique URLs. It would be awesome if Clean Pagination included an option to redirect (HTTP 301) to the clean paged path. This is especially important for existing sites installing Clean Pagination for the first time as search engines will have already crawled "mypath?page=3".

Thanks!

Comments

jdleonard’s picture

Here's my hack that's specific to a particular page on my site. Not ideal, but it seems to work. Fortunately I only have one page with a single pager that I need this for, but I'm sure others would benefit from a proper solution.

/**
 * Implements hook_init().
 */
function mymodule_init() {
  // Redirect from non-clean-paginated path for mypath to clean paginated path
  $current_path = request_path();
  if ($current_path == 'mypath') {
    $current_query = drupal_get_query_parameters();
    if (isset($current_query['page'])) {
      $page = (int) $current_query['page'];
      if ($page > 0) {
        unset($current_query['page']);
        drupal_goto('mypath/page/' . $page, array('query' => $current_query), 301);
      }
    }
  }
}
j_ten_man’s picture

Status: Active » Fixed

Good call. This is now in the dev release. Will be in the next release. Both 6.x and 7.x versions.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jdleonard’s picture

Works like a charm, thanks!

Anonymous’s picture

Status: Closed (fixed) » Active

Hello,

I've installed the dev version of this wonderful module and noticed an error when it comes to this issue:

This webpage has a redirect loop.
The webpage at http://www.site.com/drupal/?page=6 has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer.

Anyone else notice this error?

j_ten_man’s picture

Status: Active » Closed (fixed)

@-sam- Please open a new issue for this. I am unable to reproduce. You have another module or rewrite rule that is conflicting. If you can provide more information on other modules you have then I can possibly debug it. Open a new issue if so.