A WordPress plugin to safely and easily manage your website's HTTP redirects.
Easily and safely manage your site's redirects the WordPress way. There are many redirect plugins available. Most of them store redirects in the options table or in custom tables. Most of them provide tons of unnecessary options. Some of them have serious performance implications (404 error logging). Safe Redirect Manager stores redirects as Custom Post Types. This makes your data portable and your website scalable. Safe Redirect Manager is built to handle enterprise level traffic and is used on major publishing websites. The plugin comes with only what you need following the WordPress mantra, decisions not options. Actions and filters make the plugin very extensible.
Install the plugin in WordPress. You can download a zip via GitHub and upload it using the WordPress plugin uploader ("Plugins" > "Add New" > "Upload Plugin").
There are no overarching settings for this plugin. To manage redirects, navigate to the administration panel ("Tools" > "Safe Redirect Manager").
Each redirect contains a few fields that you can utilize:
This should be a path relative to the root of your WordPress installation. When someone visits your site with a path
that matches this one, a redirect will occur. If your site is located at
http://example.com/wp/ and you wanted to redirect
http://example.com, your "Redirect From" would be
Clicking the "Enable Regex" checkbox allows you to use regular expressions in your path. There are many great tutorials on regular expressions.
You can also use wildcards in your "Redirect From" paths. By adding an
* at the end of a URL, your redirect will
match any request that starts with your "Redirect From". Wildcards support replacements. This means if you have a
wildcard in your from path that matches a string, you can have that string replace a wildcard character in your
"Redirect To" path. For example, if your "Redirect From" is
/test/*, your "Redirect To" is
http://google.com/*, and the requested path is
/test/string, the user would be redirect to
This should be a path (i.e.
/test) or a URL (i.e.
http://example.com/wp/test). If a requested path matches
"Redirect From", they will be redirected here. "Redirect To" supports wildcard and regular expression replacements.
HTTP status codes are numbers that contain information about a request (i.e. whether it was successful, unauthorized, not found, etc). You should almost always use either 302 (temporarily moved) or 301 (permanently moved).
srm_max_redirectsthat you can utilize to up this number.
srm_additional_status_codesfilter to add status codes if needed.
By default redirect loop detection is disabled. To prevent redirect loops you can filter
add_filter( 'srm_check_for_possible_redirect_loops', '__return_true' );
By default every matched URL is redirected. To only redirect matched but not found URLs (i.e., 404 pages), use
add_filter( 'srm_redirect_only_on_404', '__return_true' );
The following WP-CLI commands are supported by Safe Redirect Manager:
wp safe-redirect-manager list
List all of the currently configured redirects.
wp safe-redirect-manager create <from> <to> [<status-code>] [<enable-regex>] [<post-status>]
Create a redirect.
<to> are required parameters.
<from>: Redirect from path. Required.
<to>: Redirect to path. Required.
<status-code>: HTTP Status Code. Optional. Default to
<enable-regex>: Whether to enable Regular expression. Optional. Default to
<post-status>: The status of the redirect. Optional. Default to
wp safe-redirect-manager create /about-us /contact-us 301
wp safe-redirect-manager delete <id>
Delete a redirect by
wp safe-redirect-manager update-cache
Update the redirect cache.
wp safe-redirect-manager import <file> [--source=<source-column>] [--target=<target-column>] [--regex=<regex-column>] [--code=<code-column>] [--order=<order-column>]
Imports redirects from a CSV file.
<file>: Path to one or more valid CSV file for import. This file should contain redirection from and to URLs, regex flag and HTTP redirection code. Here is the example table:
You can also use exported redirects from "Redirection" plugin, which you can download here: /wp-admin/tools.php?page=redirection.php&sub=modules
--source: Header title for source ("from" URL) column mapping.
--target: Header title for target ("to" URL) column mapping.
--regex: Header title for regex column mapping.
--code: Header title for code column mapping.
--order: Header title for order column mapping.
wp safe-redirect-manager import-htaccess <file>
Import .htaccess file redirects.
Follow the configuration instructions above to setup the plugin. We recommend developing the plugin locally in an environment such as WP Local Docker.
Within the terminal change directories to the plugin folder. Initialize your unit testing environment by running the following command:
bash bin/install-wp-tests.sh database username password host version
Run the plugin tests:
If you identify any errors or have an idea for improving the plugin, please open an issue.
Safe Redirect Manager is available in English and other languages. A listing of those languages and instructions for translating the plugin into other languages is available on Translating WordPress. Many thanks to the contributors on the translation teams!
Active: 10up is actively working on this, and we expect to continue work for the foreseeable future including keeping tested up to the most recent version of WordPress. Bug reports, feature requests, questions, and pull requests are welcome.
A complete listing of all notable changes to Safe Redirect Manager are documented in CHANGELOG.md.
Please read CODE_OF_CONDUCT.md for details on our code of conduct, CONTRIBUTING.md for details on the process for submitting pull requests to us, and CREDITS.md for a listing of maintainers of, contributors to, and libraries used by Safe Redirect Manager.