vip_regex_redirects

Advanced 301 redirects using regex to match and redirect URLs.

Warning: Since regex is expensive and this will be run on every uncached pageload, you’ll want to keep this small, lean, and mean.

Some examples:

Redirecting from /2011/12/dont-miss-it-make-live-holiday-giveaway.html (extra .html at the end) ‘|/([0-9]{4})/([0-9]{2})/([0-9]{2})/([^/]+).html|’ => ‘|/$1/$2/$3/$4/|’

Redirecting from /archive/2011/12/dont-miss-it-make-live-holiday-giveaway ‘|/archive/([0-9]{4})/([0-9]{2})/([^/]+)/?|’ => ‘|/$3/|’ // since we don’t have the day, we should just send to /%postname% then WordPress can redirect from there

Redirecting from /tax-tips/how-to-get-a-tax-break-for-summer-child-care/04152011-6163 (/%category%/%postname%/%month%%day%%year%-%post_id%) ‘|/([^/]+)/([^/]+)/([0-9]{1,2})([0-9]{1,2})([0-9]{4})-([0-9]{1,})/?|’ => ‘|/$5/$3/$4/$2/|’

Parameters

Name Type Description
$vip_redirects_array array Optional. Array of key/value pairs to redirect from/to.
$with_querystring bool Optional. Set this to true if your redirect string is in the format of an absolute URL. Defaults to false (just the path).

Return Value

void

Ready to get started?

Drop us a note.

No matter where you are in the planning process, we’re happy to help, and we’re actual humans here on the other side of the form. 👋 We’re here to discuss your challenges and plans, evaluate your existing resources or a potential partner, or even make some initial recommendations. And, of course, we’re here to help any time you’re in the market for some robust WordPress awesomeness.