Where Redirects Are Set Up: Server Files, Plugins and Site Settings
The rule is short. Finding where to put it takes longer, because it depends on how your site is run. Three common setups cover most small websites: a hosted site builder, a site with a plugin, and a server you can edit.
Start by asking who controls the server
Google's advice for a platform like Blogger or Shopify is to check first, since the platform may already have built-in redirect tools. Search that platform's help pages for its redirect feature.1
On a hosted builder you may not be able to touch server files at all. Look for a settings screen that asks for the old address and the new one, use it, and then test the result.
Site with a plugin
Many sites made with a content management system, which is software that stores pages and settings in a database, have redirect plugins or built-in redirect screens. They work like the hosted builder: two boxes and a choice of code. Pick the permanent code for a page that has moved for good, as Google advises.1 The page on codes has the detail.
Google's guide for site moves mentions the same idea: redirect functions in your CMS are one way to do it.2
Apache
Apache is a common web server. Its mod_alias module has a Redirect line, and the rule can sit in the main server configuration, in a virtual host, in a directory block, or in an .htaccess file.3 An .htaccess file is a small settings file kept inside your site's folders.
An example from the Redirect section of Apache's mod_alias page:
Redirect permanent "/one" "http://example.com/two"
The permanent word makes it return a 301.3 Leave it out and you get a temporary redirect. Old paths are case-sensitive, so /About and /about are different.3
Follow Apache's documentation for your version, and check with your host before editing server files.
Nginx
On Nginx, the return and rewrite directives send redirects. A rewrite rule can end with redirect, which returns a temporary redirect with the 302 code, or permanent, which returns a permanent one with the 301 code.4
MDN shows a short server block that uses return 301 to send one hostname to another.5 If you don't run the server yourself, ask your host before changing any of this.
Other servers
MDN notes that IIS uses an <httpRedirect> element.5 For any other web server, Google says to ask your server manager or hoster, or to search for guides for that server.1
After you set the rule
Open the old address and check what it returns. Redirect rules that look right can be overruled by another rule somewhere else, and that's how loops start. To read the code and the destination, use the curl method in how to check an address.
Cited material
- Redirects and Google Search, Google Search Central
- Site move with URL changes, Google Search Central
- Apache Module mod_alias, Apache HTTP Server Project
- Module ngx_http_rewrite_module, nginx.org
- Redirections in HTTP, MDN Web Docs