A 301 tells browsers and search engines that a page has moved permanently. Set them up when URLs change, or the old addresses start returning errors.
Three ways to do it
| A plugin | Easiest. Redirects live in the database and are managed from the admin screen. |
.htaccess | Apache only. Faster, because the redirect happens before WordPress loads. WordPress documents the default file in its Apache configuration guide. |
| Server config | nginx and similar. Fastest, but you need access to the config file. |
For a handful of redirects any of these is fine. For hundreds, do it at server level. Plugin-based redirects add a database lookup to requests that miss.
301 or 302?
Use a 301 when the move is permanent. Search engines pass ranking signals through it and eventually replace the old URL with the new one in their index. A 302 says the move is temporary and keeps the old URL in the index. Using a 302 for a permanent move is a common and costly mistake.
Things that go wrong
- Chains. A redirecting to B redirecting to C. Point A straight at C.
- Loops. A points at B and B points back at A. The page never loads.
- Everything sent to the homepage. Lazy and wasteful. Redirect each old URL to its closest match.
- Browser caching. Browsers cache 301s hard. Test in a private window, or you will keep seeing the old behaviour.