Preserving links when converting from PHP-Nuke to Drupal

When I converted MacMegasite to Drupal it broke all of the old article links. It seems that a lot of people were still using old URLs, probably from pages cached at search engines. The first thing I did was redirect article links, which was easy since the story IDs remained the same. The rule I added converted a URL containing sid=nnn to a URL of the form ?q=node/view/nnn. I originally had it test specifically for name=News and the full article URL, but I found that a lot of queries broke it. I finally settled on the most liberal rule which looks for any query containing ‘&sid=’.

Checking my access logs I found that a lot of people were using direct links to reviews, downloads, or polls. Since the IDs have changed and reviews are now an article topic, I simply redirect any URL to the home page for that content type.

Here’s the final set of rules I’m using now:

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{QUERY_STRING} ^.*&sid=([^&]+)
  RewriteRule modules.php index.php?q=node/view/%1 [L]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{QUERY_STRING} ^name=Forums
  RewriteRule modules.php index.php?q=forum [L]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{QUERY_STRING} ^name=Downloads
  RewriteRule modules.php index.php?q=filestore2 [L]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{QUERY_STRING} ^name=Reviews
  RewriteRule modules.php index.php?q=article/reviews [L]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{QUERY_STRING} ^name=Surveys
  RewriteRule modules.php index.php?q=poll [L]

Comments are closed.