A 301 redirect is a server response that says a page has moved permanently. When a browser or crawler requests the old URL, the server answers with the status code 301 and the new address. The browser then loads the new address automatically, so the visitor barely notices. Hypertext Transfer Protocol (HTTP) status codes are how servers describe what happened to a request, and 301 means moved permanently.
For search engines, the word permanent matters. It signals that the old address should be replaced by the new one in the index, and that the signals the old page earned, such as links pointing to it, should carry over to the new address. This is why a 301 is the standard tool when you rename a page, restructure URLs, move from http to https or change domains.
It differs from a 302, which means found, or temporary. A 302 tells search engines the move may not last, so they may keep the old URL in mind. Using the wrong one is a common mistake. Another is building chains, where A redirects to B and B to C, which slows visitors and wastes crawling. Redirect straight to the final destination instead. Sending everything to the homepage, rather than to the closest matching page, is also unhelpful.
Where you set it depends on the setup. On shared hosting it is often a rule in a server configuration file or a plugin, while on a platform such as Vercel it is a redirect rule in the project's configuration. A site built with static site generation needs the rules defined on the host, since there is no server code to add them.
An example: /old-pricing returns a 301 to /pricing, and links to the old address now land on the new page.
Related: shared hosting, Vercel, static site generation