Using Custom Rules in the Redirection Manager

In this article we'll explain how to use the Custom Rules options in our Redirection Manager.

Using Custom Rules

To use this feature, go to Redirects in the All in One SEO menu and you'll see the Add New Redirection form.

Add New Redirection form on the Redirects screen in All in One SEO

Click on the Advanced Settings link to display the Custom Rules fields.

Custom Rules fields in the Add New Redirection form

You'll see a drop down where you can select the rule type, and a field where you can enter the value to match on.

Here's an explanation of each of the rule types:

Login Status

Use this option to match redirects by the user login status. You can redirect a visitor if they're either Logged In or Logged Out of your site.

Login Status selected in the Custom Rules fields

WordPress User Roles

Use this option to match redirects by the user role for logged in users. You can set multiple roles like Author and Editor to match one or the other.

WordPress User Roles selected in the Custom Rules fields

Referrer

Use this option to match redirects by the referrer. Click on the Regex toggle to use regex to match the values.

Referrer selected in the Custom Rules fields

User Agent

Use this option to match redirects by the user agent. Click on the Regex toggle to add your own values or use our predefined options.

User Agent selected in the Custom Rules fields

Here's an explanation of our predefined options:

  • Mobile: This option will regex match any of these mobile user agents:
iPad|iPod|iPhone|Android|BlackBerry|SymbianOS|SCH-Md+|Opera Mini|Windows CE|Nokia|SonyEricsson|webOS|PalmOS
  • Feeds: This option will regex match any of these feed user agents:
Bloglines|feed|rss
  • Libraries: This option will regex match any of these library user agents:
cURL|Java|libwww-perl|PHP|urllib

Use this option to match redirects to cookies. Click on the Regex toggle to use regex to match the values.

Cookie selected in the Custom Rules fields

IP Address

Use this option to match redirects by IP address.

IP selected in the Custom Rules fields

Click on the Regex toggle to use regex to match the values.

IP rule with regex in the Custom Rules fields

Server

Use this option to match redirects to a server. Click on the Regex toggle to use regex to match the values.

Server selected in the Custom Rules fields

HTTP Header

Use this option to match redirects to a HTTP header. Click on the Regex toggle to use regex to match the values.

HTTP Header selected in the Custom Rules fields

WordPress Filter

Use this option to set custom filters. The filter name will be executed when trying to match a redirect.

WordPress Filter selected in the Custom Rules fields

The filter return value will always be ‘false' meaning the filter will never match. Use the filter and return a ‘true' value to have the rule match.

add_filter( 'aioseo_custom_filter', function ( $match, $url, $redirect ) {
if ( ! empty( $_GET['do-redirect'] ) ) {
$match = true;
}

return $match;
}, 10, 3 );

Locale

Use this option to match redirects to a locale. Click on the Regex toggle to use regex to match the values.

Locale selected in the Custom Rules fields

Multiple Rules

You can add multiple rules combining any of the above by clicking on the Add Custom Rule button.

Multiple rules will behave as an AND match.

Example: The Login Status and Locale rule below will match as: Use is Logged In AND their Locale is en_GB.

Example showing multiple custom rules

This feature was added in All in One SEO Pro version 4.1.2.