The plugin redirects legacy URLs a previous version of a websites that has since been converted into a WordPress site. It can also be used for other redirecting, eg having a short URL that directs to a page as part of a campaign.
Can be directed to:
Simply by adding ‘old-page.html’ as a custom field when editing new-page within WordPress.
Every time a 404 page is called, the Legacy URL plugin checks the database and if it find a legacy-url value that exactly matches the URL it will redirect to the new page.
Please note that this plugin has no settings/options pages within the WordPress admin module.
Things to note
- The plugin converts the url it checks to lowercase, so you should enter the meta value as lowercase.
- The URL is exactly as stated. Eg if you have query strings that can variable you would need to treat each one seperately.
- There is no reason why you can’t have multiple legacy-url meta values associated with a single page. If you have the same meta value associated with multiple pages, the programme will call the first one it finds.
- This is a simple solution, and possibly quite inefficient. It uses header redirects so will effectively process one page and then load another.
- Because it redirects, search engines will not store the campaign/legacy URL but the page it is redirected to. The more sensible ones (eg Google) will note the redirected page and update their internal databases.
- You can change the name of the custom field that the plugin searches by amending the function itself.
- Updated to make use of meta_query functionality
- Revised method of getting url to check against, removing need for str_replace functionality.
- Cleared unnecessary cnstant definition, brackets and spaces
- Added additional commenting to help amend plugin.
- Makes use of WordPress’s built-in redirect functionality.
- Uses a hook to add the plugin to the 404 page, so no longer a requirement to amend the 404 page manually.
- No longer makes distinct queries to check for posts and pages, instead searches for ‘any’ page type.