When you need to implement redirects involving your VIP site, you’ll want to choose one of the methods listed below based mostly upon how many redirects you have and expect to have going forward. This guide will help you figure out your best approach.
Because WordPress.com VIP uses nginx and not apache, there aren’t any .htaccess files to modify. Instead, we have one of three methods available. Which one you use (or combination of them) depends upon how many redirects you need to implement:
- For a small number of redirects and redirects which will change frequently, we recommend Safe Redirect Manager plugin;
- For larger numbers of redirects (> 300), you will want to use the WPCOM Legacy Redirector plugin
- Alternately, you can write redirects directly into your theme code.
Safe Redirect Manager plugin #
If you have fewer than 300 redirects, the Safe Redirect Manager plugin is the way to go. This plugin has an admin UI component, so your editors can edit redirects easily. This can be especially important for redirects that are going to change frequently. Safe Redirect Manager also supports regex and wildcards, so if you require that, this is a good option.
WPCOM Legacy Redirector plugin #
While this is a plugin, there is no UI. Data entry needs to be bulk-loaded via wp-cli commands. As you might imagine, this option is not ideal for redirects that need to change frequently.
Two options come with the plugin:
- Build redirects from CSV. We just need a CSV file with the following mapping structure: `redirect_from_path,(redirect_to_post_id|redirect_to_path|redirect_to_url)`
- Build redirect from a meta field. Just provide the meta_key for posts where the legacy URLs are stored.
Be sure to review the documentation http://vip.wordpress.com/plugins/wpcom-legacy-redirector/. Please contact us before using this plugin to verify your redirect strategy.
Writing redirects directly into your theme code #
VIP has a couple of helper functions for broader redirects.
- 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.
- vip_substr_redirects - wildcard redirects based on the beginning of the request path. This is basically an alternative to vip_regex_redirects() for when you only need to redirect /foo/bar/* to somewhere else. Using regex to do this simple check would add lots of overhead.
Additional Resources #
External Permalinks Redux Plugin