Migrating Joomla articles to a new website and maintain Joomla’s legacy links with .htaccess rewrite rules

Moving from Joomla to WordPress can be easy with a little planning.  One problem is the “legacy” links from Joomla that aren’t so search engine friendly.  When migrating to your new site, there are a lot of old links still out there.  You don’t want to frustrate your visitors with 404 “page not found” errors just because the old Joomla organization and page URLs were different.  With two lines of code, you can drastically reduce your 404 errors and keep everyone happy.  You will have to alter your .htaccess rewrite rules but hopefully you can pick up on the general pattern set below and find ways to accommodate as many old links into the new site as possible.

Put this code into your .htaccess file, you may have to change the /(.*)/ folders or some other logic based on how your old Joomla site was organized, but this worked great to help maintain old links out there, improving our site’s performance, customer satisfaction AND SEO rankings.  Keep in mind that the # hashtags in .htaccess files are comments and don’t do anything.

Basically, this rewrite ignores all the extra paths and query variables inbetween the actual link between your Joomla articles and your new site.  As long as your url (slug) for an article remains the same, an exact match on your new website will be found.  This works for WordPress and Drupal as well.  Migration and maintaining the integrity of your old website’s legacy links is a vital strategy to ensure you won’t lose visitors, followers and fans all while keeping the search engines happy.  Some pages you may still have to manually create rewrite rules or even redirect visitors, but with these two rewrite rules, you are taking care of probably 90% of old links if you are moving from Joomla to WordPress.  Too many rewrite rules in .htaccess can increase lag times, so it’s best to find the most efficient way to accomplish accommodating your legacy links.


#    /News/news-by-id-handler-maybe-old-joomla-articles.php?id=14703&catid=1&title=article-title-here
#    RewriteRule ^News/news-by-id-handler-maybe-old-joomla-articles.php?id=([0-9])&catid=([0-9])&title=(.*)/$   /$3 [R=301,L,NC]

RewriteCond %{THE_REQUEST} /News/news-by-id-handler-maybe-old-joomla-articles.php\?id=([^&]+)&catid=([^\s&]+)&title=([^\s&]+) [NC]
RewriteRule  ^  /%3? [R=301,L,NC]

#Old Joomla articles:  /News/99999/999/article-title-here/
RewriteRule ^News/(.*)/(.*)/(.*)/$   /$3 [R=301,L,NC,QSA]

About Author:

Senior Cloud Software Engineer and 25+ years experienced video production, video editing and 3D animation services for a variety of global clients including local video production here in Jacksonville, Florida.

Leave a Comment

Your email address will not be published. Required fields are marked *