Attached is a patch that allows administrators to setup an expire time on each path redirect. After the path has expired it will be purged from database.

Many administrator need path redirects when they change paths patterns on their sites for SEO reasons. Search engines will update their indexes for a while and those path redirects are practically not needed. Why should we keep them in the database?

This patch simply adds two new columns to path_redirect table: expire (the amount of seconds in which the path will expire) and changed (the last updated time - from which the expiration time will be calculated). Setting the "expire" period to zero means that the redirect is permanent and will never expire. This is the default value. Then the cronjob do the rest through hook_cron().

TODO: As a logical approach, the Pathauto should set an expiry value when this module uses Path Redirect for dealing with paths changes. This can be the subject of a Pathauto patch if this feature is welcomed by the community.

CommentFileSizeAuthor
path_redirect_with_expire.patch7.07 KBclaudiu.cristea

Comments

dave reid’s picture

Assigned: claudiu.cristea » Unassigned
Status: Needs review » Closed (duplicate)

I have just added a feature very similar to this (see #204632: Automatic cleaning non-used redirects). It accomplishes pretty much the same thing so I'm going to mark this as a duplicate.