After upgraded the pagination links are showing:

http://www.site.ext/node?page=1

While with the other Drupal version it was:

http://www.site.ext/node?from=10

I tried redirecting all the pagination pages to the new one with htaccess:

RewriteEngine on
RewriteRule node?from=(.*) http://www.url.ext/node?page=$1 [R=301,L]

But isnt working, any idea what failing?

Comments

mooffie’s picture

RewriteRule node?from=(.*) ......

(Note that '?' has a special meaning (it's somewhat like a wildcard), so you have to escape it with '\' )

But isn't the number after 'from=' the number of nodes? If it is then you'll have to do arithmetic, because the number after 'page=' is the number of pages. mod_rewrite probably isn't very good for arithmetic.

I suggest you put the translation/redirection code in 'settings.php'. Something along the lines of:

if (isset($_GET['from'])) {
  $_GET['page'] = (int)($_GET['from'] / 10);
  unset($_GET['from']);
}

But that's just a start. The code to do HTTP redirection (so as to notify search engines) is more involving. I don't have the time now to write/test/debug it, sorry, but I hope I provided some useful info here.

Didaci’s picture

Thanks for the help, but i guess i am not good enough with php to solve it. I thought it would work just with a htaccess redirection but as i see its imposible, i will have to leave it.

Anyway i wonder why nobody had the same problem i dont think i am the one upgrading an old version to the 5.3.

mooffie’s picture

i wonder why nobody had the same problem

Links to 'pages' are volatile. Every time some nodes are added to the site the pages 'shift'. An 'example.com/node?page=3' URL today is obsolete tomorrow (e.g., the nodes may have shifted to 'page=5'). Such links are valid for a limited amount of time, so there's no need to preserve such old links.

Didaci’s picture

I know but the problem is

node?from=* has the same content of the index pages. So google will take it as duplicated content.

Both links are working now (node=from=*) and (node?page=*).

mooffie’s picture

Where are these 'from=' links?

Are they spread in various forums on the internet? or are they remembered only by google? Beacuse if you don't mind totally breaking old 'from=' links, you can simply redirect them to the front page:

if (isset($_GET['from'])) {
  header("HTTP/1.1 301 Moved Permanently");
  header("Location: http://example.com");
  exit();
}

(We're making this shortcut to avoid writing a more complicated code.)

Didaci’s picture

They are just cached by google, where would i put that code?

mooffie’s picture

BTW, I've rewritten that message at least... 5 times ;)

Put it in your settings.php.

Didaci’s picture

Thanks it works now.

One last question, i tried to sent a 404 error with this code:

if (isset($_GET['from'])) {
header("HTTP/1.0 404 Not Found");
exit();

It works but isnt showing the 404 drupal page, just a blank page, how could i show that?

Thanks for your help.

mooffie’s picture

In 'settings.php' Drupal isn't really loaded yet, so you can't show Drupal's 404 page here. (You'll have to write a more complex code if that's what you want.)

But why do you want to impress Google with Drupal's nifty 404 page? Google doesn't care about beauty. A simple "not found" message will suffice:

if (isset($_GET['from'])) {
  header("HTTP/1.0 404 Not Found");
  print "Page not found\n";
  exit();
}

Frankly, I don't think you need to bother with all this. I believe google is smart enough to forget your 'form=' pages itself. And in any case it's not going to think badly of your site, because what it's going to find at your site isn't a duplicate of these pages anymore. In the beginning I thought you wanted to preserve existing links you published in various places.... only later I understood this isn't the case. If I were you I would do absolutely nothing.

Didaci’s picture

No, it was just about google. I think its ok now.

Thanks for your help.