Redirection is a WordPress plugin to manage 301 redirections, keep track of 404 errors, and generally tidy up any loose ends your site may have. This is particularly useful if you are migrating pages from an old website, or are changing the directory of your WordPress installation.
Note: this is the current 'trunk' version of Redirection. It may be newer than what is in the WordPress.org plugin repository, and should be considered experimental.
Redirection can be installed by visiting the WordPress.org plugin page:
https://wordpress.org/plugins/redirection/
The following WordPress filters are available for customisation of a server requests:
redirection_request_url
- The request URLredirection_request_agent
- The request user agentredirection_request_referrer
- The request referrerredirection_request_ip
- The request IP addressredirection_request_cookie
- The request cookieredirection_request_header
- The request HTTP header
The following WordPress filters are available for customisation of logged data:
redirection_404_data
- Data to be inserted into the 404 tableredirection_log_data
- Data to be inserted into the redirect log tableredirection_log_404
- Return true if the current 404 page should be logged, false otherwiseredirection_log
- Action fired when something is logged
Note that returning false
from the filter will bypass the log.
redirection_url_source
- The original URL used before matching a request. Return false to stop any redirectionredirection_url_target
- The target URL after a request has been matched (and after any regular expression captures have been replaced). Return false to stop any redirection
redirection_do_nothing
- Called when a 'do nothing' action fires
The following special words can be inserted into a target URL:
%userid%
- Insert user's ID%userlogin%
- Insert user's login name%userurl%
- Insert user's custom URL
redirection_permalink_changed
- return boolean if a post's permalink has changedredirection_remove_existing
- fired when a post changes permalink and we need to clear existing redirects that might affect itredirection_monitor_created
- fired when a redirect is created for a monitor post type. Supplied with the new redirect, old post, and post IDredirection_monitor_types
- Modify what post types are monitored by Redirectionredirection_create_redirect
- Modify redirect data before a redirect is createdredirection_update_redirect
- Modify redirect data before a redirect is updatedredirection_validate_redirect
- Validate redirect datared_default_options
- The default Redirection optionsredirection_save_options
- Modify options before they are savedredirection_redirect_deleted
- Action fire when a redirect is deletedredirection_redirect_updated
- Action fire when a redirect is updated/createdredirection_redirect_deleted
- Action fire when a redirect is deleted
Additionally, if the target URL is a number without any slashes then Redirection will treat it as a post ID and redirect to the full URL for that post.
Access to the Redirection admin interface is given to users who can manage_options
. You can modify this with the filter redirection_role
, returning your
own WordPress access level or capability
Redirection is mostly a PHP plugin, but does contain files that need to be built. For this you'll need Gulp, Node, and Yarn installed. Install required modules with:
yarn install
gulp pot
- Updates language files
Some parts of the UI are React and can be built with:
yarn run dist
To use in development mode then set REDIRECTION_DEV_MODE
to true in PHP, and run:
yarn start
This will start Webpack in hot-reload mode, and you can make changes to JS files and have them auto-loaded.
Finally, to produce a release copy:
gulp svn
Please raise any bug reports or enhancement requests here. Pull requests are always welcome.
You can find a more detailed description of the plugin on the Redirection home page
Translations can be added here:
https://translate.wordpress.org/projects/wp-plugins/redirection