Skip to content
A simple HTTP redirection plugin for WordPress.
Branch: develop
Clone or download
Latest commit c3b0230 May 21, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Add workflow file for deployments May 21, 2019
.wordpress-org Add .org assets May 21, 2019
bin Fix testing Nov 26, 2018
inc Rename cli list to fix php 5 reserved keyword error. Fixes #158 Nov 27, 2018
lang Update pot file Nov 22, 2018
tests
.editorconfig Remove yarn; phpcs Nov 22, 2018
.gitattributes Add directive for bin May 21, 2019
.gitignore Continue refactor Nov 26, 2017
.travis.yml Fix tests Mar 21, 2019
README.md Merge pull request #166 from adamsilverstein/patch-1 May 21, 2019
composer.json Fix tests Mar 20, 2019
composer.lock Update WPA Mar 21, 2019
package-lock.json Remove yarn; phpcs Nov 22, 2018
package.json Remove yarn; phpcs Nov 22, 2018
phpcs.xml Fix phpcs Mar 20, 2019
phpunit.xml.dist Add WPA tests Mar 19, 2019
readme.txt bump tested up to -> 5.2 May 1, 2019
run-wpacceptance.sh Fix tests Mar 21, 2019
safe-redirect-manager.php Rename cli list to fix php 5 reserved keyword error. Fixes #158 Nov 27, 2018
wpacceptance.json Fix tests Mar 21, 2019

README.md

Safe Redirect Manager Build Status WordPress tested up to version

A WordPress plugin to safely and easily manage your website's HTTP redirects.

Purpose

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.

Installation

Install the plugin in WordPress. You can download a zip via Github and upload it using the WP plugin uploader.

Non-English Usage

Safe Redirect Manager is available in English, French, and Slovak. Instructions for translating the plugin into other languages are below.

Configuration

There are no overarching settings for this plugin. To manager redirects navigate to the administration panel. Within the main menu, click "Tools" > "Safe Redirect Manager".

Each redirect contains a few fields that you can utilize:

"Redirect From"

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/wp/about to http://example.com, your "Redirect From" would be /about.

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 http://google.com/string.

"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 Code"

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.

Note:

  • Redirects are cached using the Transients API. Cache busts occur when redirects are added, updated, and deleted so you shouldn't be serving stale redirects.
  • By default the plugin only allows at most 250 redirects to prevent performance issues. There is a filter srm_max_redirects that you can utilize to up this number.
  • "Redirect From" and requested paths are case insensitive by default.

Redirect loops

By default redirect loop detection is disabled. To prevent redirect loops you can filter srm_check_for_possible_redirect_loops.

add_filter( 'my_srm_redirect_loop_filter', '__return_true' );

Development

Setup

Follow the configuration instructions above to setup the plugin. I recommend developing the plugin locally in an environment such as WP Local Docker.

Testing

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:

phpunit

Issues

If you identify any errors or have an idea for improving the plugin, please open an issue.

You can’t perform that action at this time.