9 min read
Redirects: what they are, which types exist and how to set them up
A redirect sends a visitor and a search robot from an old address to a new one. We explain redirect codes, setup methods and the steps to take when moving a site.

A redirect is an automatic forwarding from one address to another. The instruction to go there is given by the server or by the loaded page itself. Without correct redirects, a change of structure, domain or content management system (CMS) results in 404 errors and lost rankings. Below: types of redirects, what they mean for search and how to set them up.
What a redirect is
With a server redirect, the browser receives a redirect code from the 3xx group and the new address in the Location header. When forwarding via HTML or JavaScript, the first page may load with a normal 200 code. The browser then reads the instruction and opens the second address.
The response code communicates the nature of the forwarding: whether it is permanent or temporary. The user does not see the difference, but for a search engine it determines which address to keep in the index. That is why redirecting a site is not only a convenience but also a signal for search.
When a redirect is needed
A redirect is needed whenever a page's address changes or one page should replace another. Otherwise old links from search, bookmarks and third-party sites will lead to an error.
- moving to a new domain or from HTTP to HTTPS;
- choosing a single main address: with or without www, with or without a trailing slash;
- changing the URL structure during a redesign or a move to another CMS;
- merging similar pages and removing outdated sections;
- redirecting after a form submission so that reloading the page does not submit it again.
Types of redirects: codes 301, 302, 303, 307 and 308
Redirects are divided into permanent (301 and 308) and temporary (302, 303 and 307). A permanent one tells the search engine that the new address has replaced the old one; a temporary one says that the old address will return soon.
| Code | Name | Type | When to use |
|---|---|---|---|
| 301 | Moved Permanently | Permanent | The page has moved to a new URL for good |
| 308 | Permanent Redirect | Permanent | The same, but preserving the request method and body |
| 302 | Found | Temporary | Maintenance, a temporary promotion, page tests |
| 307 | Temporary Redirect | Temporary | A temporary move preserving the request method |
| 303 | See Other | Temporary | Going to a result page after submitting a form |
GET requests a page, while POST can send form data. For example, a store accepted an order via POST and returned 303. The browser will open the confirmation via GET, without resubmitting the order. If a handler has temporarily moved and returns 307, the browser will repeat the POST with the same data at the new address. Code 308 likewise preserves the method and data in a permanent move.
Code 304 Not Modified is often confused with a redirect, although it means something else: the page has not changed since the last visit and a copy can be taken from the cache. Yandex recommends returning it for rarely changing files, which saves crawl resources.
How search engines treat redirects
For Google and Yandex, a redirect is a signal of which address to show in search. After a permanent redirect, the new URL remains in the index; after a temporary one, the search engine may keep showing the old one.
According to Google's documentation, codes 301 and 308 are a strong signal that the new address should be considered canonical, meaning the main one for display in search, while 302, 303 and 307 are a weak signal. Google also treats an instant meta refresh with a 0-second delay as permanent, and advises using a JavaScript redirect only when a server-side option is impossible: if the page rendering fails, the robot will not see it. Google's crawlers (page-crawling programs) follow no more than 10 hops in a chain.
Yandex recommends 301 for a permanent move and advises keeping such a redirect for at least six months. A temporary 302 is needed only for temporary situations: maintenance or comparing two versions of a page.
How to set up a redirect
The most reliable way is to set up a redirect on the server: in the configuration of the Apache or Nginx web server, or in the site code. Redirects via HTML and JavaScript are left for cases where there is no access to the server.
Apache and the .htaccess file
For a single page, a line is enough: Redirect 301 /old-page/ https://example.ru/new-page/. For pattern-based rules, use the mod_rewrite module and the [R=301] flag. Note that the Redirect directive without a code returns a temporary 302 by default.
Nginx
If only the domain changes, place return 301 https://example.ru$request_uri; in the server block that serves the old name old.example.ru. For example, a request to https://old.example.ru/catalog/?page=2 will receive the new address https://example.ru/catalog/?page=2. The $request_uri variable preserves the path and query parameters. On the new host, the same rule would send the visitor back to the same address and create a loop. For a pattern-based move, rewrite with the permanent flag is suitable. Nginx does not read .htaccess files, so rules carried over from Apache must be rewritten.
PHP and other languages
In code, a redirect is sent with headers before any content is output: header("Location: https://example.ru/new/", true, 301); and then the script execution is terminated.
HTML and JavaScript
The meta tag <meta http-equiv="refresh" content="0; url=https://example.ru/new/"> and changing window.location in JavaScript work only in the browser after the page loads. These are fallback options, not the main method.
In a CMS
Many CMSs and website builders allow redirects to be added in the admin panel or via modules. This is convenient for single rules, but hundreds of redirects during a move are better kept in the server configuration: they are easier to check and do not slow the site down.
Moving a site and the 301 redirect map

For every page that has a new version, set up a permanent redirect to that version. To do this, a redirect map is prepared in advance: a table matching old and new addresses.
When changing the domain and when moving a section within a site, start with the same steps.
- Collect all old URLs: from the XML sitemap, a crawler export, Yandex Webmaster and Search Console reports, and traffic statistics.
- Match old pages to suitable new ones by meaning. If a service was discontinued and there is no replacement, the old address can return 404 (not found) or 410 (gone for good). Do not redirect everything to the home page: Yandex notes that this is inconvenient for users and slows the indexing of the new site.
- Set up redirects directly, without chains. Even if both the domain and the path change, take the visitor from each old address straight to the final new one.
- Update internal links, canonical pointers (rel="canonical") and the sitemap so that they point to the new addresses.
- Check that the new pages are indexed and monitor for 404 errors.
If the domain has changed, additionally submit a request from the old site in Yandex Webmaster ("Indexing" → "Site move") and use the address change tool in Google Search Console. Monitor reports for both domains. If only the page paths on the same domain have changed, a move request is not needed.
In its guide to site moves, Google advises keeping redirects in place for as long as possible, as a rule for at least a year. Changing the main address in Yandex, according to its help, takes several weeks. Technically, it is easier to entrust the move to those who handle site migration as a whole: server, CMS and redirects.
How to check a redirect
You can check a redirect in the browser, in the server console or in search engine tools. Look at three things: the response code, the final address and the number of intermediate hops.
- Browser developer tools. On the Network tab, with the preserve log option enabled, the whole chain with response codes is visible.
- The command line. The request curl -I https://example.ru/old/ will show the code and the Location header.
- Webmaster panels. "Server response check" in Yandex Webmaster and URL Inspection in Search Console show what the search robot sees.
- Crawlers and online services. They check the whole site at once or a list of addresses from the redirect map.
Common mistakes when setting up redirects
Most redirect problems come down to three things: the wrong code, unnecessary intermediate steps and forwarding to the wrong place. All of them are easy to find when checking after release.
| Mistake | Consequence | Solution |
|---|---|---|
| 302 instead of 301 for a permanent move | Search may keep the old address in the index | Change the code to 301 or 308 |
| A chain of several redirects | Slower for people, worse for crawling | Lead straight to the final URL |
| A redirect loop | The browser shows a "too many redirects" error | Find the conflict between server rules and the CMS |
| All old pages lead to the home page | The user does not find what they need and indexing slows | Redirect to a page close in meaning |
| Internal links lead to old addresses | Extra hops on every click | Replace links with the new URLs |
| Redirects removed a month after the move | Old links lead to 404 again | Keep redirects in place for a long time |
If the site is due for a move or a change of structure, the redirect map and its check should be included in technical SEO for the site before release, not after traffic falls.
Sources
Questions and answers
What is a redirect?
It is an automatic transition from one address to another. With a server redirect, the new address arrives in the Location header together with the redirect code. The transition can also be started by HTML or JavaScript on the loaded page.
Where is a redirect set up?
Most often in the web server configuration (.htaccess for Apache, Nginx files) or in the site code. In a CMS, redirects can be added through the admin panel or a module.
How do I remove a redirect?
Delete the rule where it is defined: in the server configuration, the code or a CMS module, then clear the cache. Bear in mind that browsers may remember a permanent 301, so check the result in incognito mode or via curl.
How should I set up forwarding of a site to a new domain?
Redirect each old page to the corresponding new one with a 301 code, update the sitemap and internal links, then report the move in Yandex Webmaster and Google Search Console.
How does 301 differ from 302?
301 says the address has changed for good, and the new page stays in search. 302 means a temporary move, and the search engine may keep showing the old URL.
Follow the journal
New pieces on websites, SEO and AI come out in the QIO journal. Follow in Google, by RSS or in Telegram to get them first.


