How to purge all unnecessary URLs of Joomla Redirect component

How to purge all unnecessary URLs of Joomla Redirect component

As we all know, Redirect component keeps and stores all URL requests including wrong links that are disabled by default in Database table. During years of website usage, you may get tens of thousands disabled items which increase Database size and it’s pretty hard to remove all these items manually because of its huge number, moreover you have to perform such action twice since it’s needed to remove items (send to trashing can) and then clean all trashed items which are equal action. Here is a solution how to purge all disabled and trashed items of Redirect component.

Redirect component is a good solution when you need to create a redirect URL quickly, without using a magic of mod_rewrite and especially it’s became actual when you migrating a website from another CMS or just changed the navigation structure and want to keep up incoming traffic from old URLs.

In most cases you don’t need to use Redirect component (com_redirect), since it stores all URL requests even wrong ones, if it’s enabled. During the time you shall get thousands of links, which becomes an actual problem, especially if the website had been scanning by virus bots and there were automatic attempts to hack the website and finally get remote access. Thus, Redirect component does not help you to avoid attacks, but will save extra data. As a result, you'll get thousands of disabled URLs like on the pic below:

Example of wrong Joomla URLs
Example of wrong URLs. Take an attention at the number of pages.

Thus, Redirect component becomes a “dust collector” and its Database tables swells from unusual data. It’s not a problem if you have a few dozens of links, but how to avoid storing unnecessary data which your website have collected during years of use and how to keep up the component enabled because of useful redirects?

Here is a quick solution which provides you to purge all unwelcomed links and save only enabled links. You must execute a simple query to the database via phpmyadmin panel:

DELETE FROM PREFIX_redirect_links WHERE published IN (0,2,-2)

Where PREFIX - a prefix of your Database.

As a result of this query, all disabled, archived and trashed items of Redirect component (com_redirect) will be purged from _redirect_links table. All enabled items won’t be changed.

If you don’t use Redirect extension in Joomla 3.3, just keep Redirect plugin disabled, but if you’re using it, feel free to execute such query time to time to keep your database clean.

Thanks to Dmitry Rekun for query solution.


Eugene Sivokon

About author

Eugene has been a part of and worked in many of the web development roles over the years, taking on various projects. At the present moment, he is involved as a team manager working inside his personal projects. This blog is specifically dedicated to start-up businesses, team management, and how to maximize your success with Open Source ideology.

Norrnext - extensions for Joomla and Pagekit

RoundTheme - Professional Kunena templates

NorrTheme - templates for Joomla and Wordpress