Writing redirects into a WordPress site’s theme code
Redirects can be written directly into a WordPress site’s theme code. The limitations that prevent redirects and custom rewrite rules for static assets still apply.
VIP helper functions that can be used for broader redirects:
- vip_regex_redirects() — Advanced
301redirects using regex to match and redirect URLs.
Caution: Regex is expensive and using this helper function will cause regex operations to be run on every uncached page load. - vip_substr_redirects() — Wildcard redirects based on the beginning of the request path. This is an alternative to
vip_regex_redirects()for when only a redirect from/foo/bar/*to somewhere else is needed.
Last updated: September 09, 2025