Migrating Links from Joomla 1.0 to Joomla 1.5

Recently I just upgraded my Joomla installation from 1.0 to the 1.5 release.  Yes, late I know – but the site just “worked” and there is no reason to fix what isn’t broke right?

During the upgrade, I used the Migrator component – which takes a snapshot of all your content items, menu items, modules, and other “main features” from Joomla.  However, it does not migrate over third-party plugins.

On my site, I have two plugins that are used.  One of them is to allow comments to content items (like this one) and the other is the Zoom Media Gallery.

After installing Joomla 1.5, I re-installed the old comment plugin – and then did an export of those specific tables for that plugin – and then imported them in the new database.  Perfect – worked like a dream.  Just ensure you turn on the Legacy plugin if you are using old templates or non-native components for Joomla 1.5.

I had a little more difficulty with Zoom Media Gallery.  I was able to install the component just fine – then exported the tables from the old database and imported them into the new – no problem there.  However, when I tried to view the gallery or even the configuration, it was nothing but a white screen.

Luckily someone made a “patch” for this.  I uninstalled the Zoom Media Gallery component and installed the patch – which makes very little changes to the original component – but it worked.  Re-imported the tables again – and I was in business!

So the site was converted over to Joomla 1.5 in a day.

Next problem – woops!  I posted many links on forums around the Internet with the old way that Joomla made use of the mod_rewrite Apache module.

It went from links like this:

  • http://www.bsntech.com/content/blogcategory/41/281/
  • http://www.bsntech.com/content/view/1301/281
  • http://www.bsntech.com/component/option,com_zoom/Itemid,261/
  • http://www.bsntech.com/component/option,com_zoom/Itemid,261/catid,2/

To links like this:

  • http://www.bsntech.com/bsntech-blog-mainmenu-321/computers-mainmenu-281
  • http://www.bsntech.com/bsntech-blog-mainmenu-321/computers-mainmenu-281/1301/
  • http://www.bsntech.com/index.php?option=com_zoom&Itemid=261
  • http://www.bsntech.com/picture-gallery-mainmenu-261?catid=2

See the big difference there?  Wow – I quickly made a backup of the new Joomla 1.5 installation, zipped it up, and reverted back to Joomla 1.0 until this problem was fixed.  Why?  I don’t want to lose my Google Page Ranks – and I certainly don’t want to lose all of the visitors on those forums where I posted direct-links to my blogs or specific content-items!  This would have been dreadful and would have left all of my users upset that the links no longer worked – and would reduce my visitors by at least half (if not more)!

What I needed was a Joomla 1.0 to Joomla 1.5 Link Converter.  Yeah – no such thing available.

Instead, I remembered that there was a file in the root directory called “.htaccess” – which allows the Apache mod_rewrite module to function.  So, this was the key to getting all of those links to work and automatically redirect to the correct site.

After probably 12 hours of attempting to work on this, I just opted to go to the Apache mod_rewrite documentation and look through this.

While not all of the pages are going to direct using this function (unless you make a rule for every single specific site on your main page), I only redirected the pages that are most-used through search engine hits and the like.

So here is the glory that was added to my .htaccess file.  It was added just under the line that says:

########## Begin – Joomla! core SEF Section

And for the code that was added to allow those links above to work:

RewriteRule ^content/blogcategory/51/301/$ /bsntech-blog-mainmenu-321/gardening-mainmenu-301 [R,L]
RewriteRule ^content/blogcategory/41/281/$ /bsntech-blog-mainmenu-321/computers-mainmenu-281 [R,L]
RewriteRule ^content/view/(.+)/301/$ /bsntech-blog-mainmenu-321/gardening-mainmenu-301/$1 [R,L]
RewriteRule ^content/view/(.+)/281/$ /bsntech-blog-mainmenu-321/computers-mainmenu-281/$1 [R,L]
RewriteRule ^component/option,com_zoom/Itemid,261/$ /picture-gallery-mainmenu-261 [R,L]
RewriteRule ^component/option,com_zoom/Itemid,261/catid,(.+)/$ /picture-gallery-mainmenu-261?catid=$1 [R,L]

After testing for a while, this fully took care of the most-used content on my site.

The first two lines above simply point directly to a blog category – such as when you click “Gardening Blog” or “Computer Blog” on the top of the main page.  With these two lines, it was an immediate conversion – there were not any dynamic numbers or anything to throw in.  You’ll noticed that it says “^content……/$”.  The caret in front indicates that this is the beginning of the line and the $ sign indicates the end of the line.  It will only accept this as input – any deviation from it and the redirect won’t work.  In addition, at the very end, there is [R,L] – which means Redirect (so the address bar in a user’s browser changes to the correct link) – and L – for Last.  This tells the mod_rewrite module that if this line item matches, do not process any other lines below it for comparison.

In the other lines, you’ll see a “(.+) inserted.  This tells the module that any number of characters can be inserted in this portion of the URL and is stored in the $1 variable.  Hence – that is why there is a $1 at the end of the redirect link on those lines.  Now of course if someone just types in junk in that area, it clearly will get a 404 – because it passes it directly to the way the new links are setup.  You can’t enter number 1500 if a content item with that ID doesn’t match.

Well, that takes care of the dynamic conversion of links from Joomla 1.0 to Joomla 1.5.  The site is functioning well and I believe it is very close to being fully supportive of the old link style in Joomla 1.0