Documentation
Simple Redirects
Simple redirects work similar to the format that Apache uses: the request should be relative to your WordPress root. The destination can be either a full URL to any page on the web, or relative to your WordPress root.
Example
- Request: /old-page/
- Destination: /new-page/
Wildcards
To use wildcards, put an asterisk (*) after the folder name that you want to redirect.
Example
- Request: /old-folder/*
- Destination: /redirect-everything-here/
You can also use the asterisk in the destination to replace whatever it matched in the request if you like. Something like this:
Example
- Request: /old-folder/*
- Destination: /some/other/folder/*
Or:
- Request: /old-folder/*/content/
- Destination: /some/other/folder/*
*/
function expand_redirects() {
$redirects = get_option('301_redirects');
$output = '';
if (!empty($redirects)) {
foreach ($redirects as $request => $destination) {
$output .= '