Changing domains: which HTTP redirects should you use?
301, 302, 303, 307 or 308: which HTTP redirect should you use when changing domains? Differences, SEO implications and checks with curl.
What are the different types of HTTP redirects?
For a permanent domain change, use an HTTP 301 or 308 redirect from each old URL to its equivalent on the new site. Codes 302 and 307 are for temporary moves. A 303 points to a resource to retrieve, such as a confirmation after submitting a form. Choosing between 301 and 308, or between 302 and 307, depends in particular on whether the HTTP method and request body need to be preserved.
For web pages accessed with GET, a 301 is a common choice. A 308 also suits a permanent migration and requires the method to stay unchanged if the client follows the redirect. This difference matters for an API or a form submitted with POST. Here, GET reads a page; POST can send data for processing.
How does a redirect send users to the new domain?
The server for the old domain responds with a redirect status and a Location header specifying the destination. The browser can then request this new URL. In this fictional example, /guide keeps its path and language parameter; the domain changes.
HTTP/1.1 301 Moved Permanently
Location: https://nouveau.example/guide?lang=fr
Content-Length: 0A DNS change alone does not produce this HTTP response. DNS helps find the server that responds for a domain name. Even if both names point to the same server, it still needs configuration to redirect the old name to the new one. A CNAME alone does not change the address shown in the browser.
Keep a valid TLS certificate on the old domain and any HTTPS variants in use. The secure connection is established before the redirect response: if it fails, visitors will not normally receive the expected 301 or 308.
301 or 308: which permanent redirect should you choose?
- 301 Moved Permanently: the URL has changed permanently. For historical reasons, a client may change a POST to a GET when following the redirect. Do not use it to guarantee that form data or a request body will be sent again.
- 308 Permanent Redirect: the move is also permanent. If the client follows the redirect, it must preserve the method and request body. A POST therefore remains a POST to the new URL.
Google Search Central recognises both codes as permanent redirects, providing a strong signal in favour of the new canonical URL: the preferred address for indexing. Its documentation does not give 301 a ranking advantage over 308. I would choose the code based on the requests actually received and the clients that need to keep working.
A 308 does not guarantee that an API client will follow redirects or forward its authentication to another domain. Cookies and CORS rules also need checking where relevant. Test real clients before switching over; do not replay an order or payment in production to check a POST.
301 and 308 responses can be cached, under some conditions even without an explicit lifetime. A rule corrected on the server may therefore remain visible in a cache. Check destinations in a test environment before distributing permanent redirects.
When should you use 302, 307 or 303?
- 302 Found: a temporary move. The client should keep considering the old URL for future requests. As with a 301, a POST may become a GET when following the redirect.
- 307 Temporary Redirect: a temporary move preserving the method and body. It is the temporary counterpart to the behaviour of 308.
- 303 See Other: an invitation to retrieve another resource using a read request, with GET or HEAD depending on the HTTP context. After a form POST, the browser can use a GET to display a confirmation page.
For Google, 302 and 307 do not provide the same canonical replacement signal as a permanent redirect. Reserve them for situations that are actually temporary. If the old domain is being retired permanently, configure a 301 or 308; a confirmation 303 is not a substitute for that migration decision.
What about 304 Not Modified? It indicates that a client can reuse a cached response after a conditional request. It does not move the page to another domain. Codes 300, 305 and 306 are not usual choices for this migration: 300 offers multiple representations, 305 is deprecated and 306 is no longer used.
Prepare a redirect plan for each URL
Before writing a blanket rule, map old pages to their destinations. If paths stay the same, a domain replacement rule may be enough. If a redesign changes paths, add specific mappings and check their priority in your server or hosting configuration.
Redirecting every old page to the home page may send readers to unrelated content and be treated by Google as a soft 404: a page considered to lack content despite its technical response. Return a 404 or 410 for a removal without an equivalent. Consolidation into a new page remains appropriate if it actually incorporates the content concerned.
Point directly to the final HTTPS URL using the chosen domain variant, with or without www. Avoid a chain through the old HTTP domain, the old HTTPS domain, the new domain and then the new path. Also check useful parameters: dropping a product identifier or filter can change what readers find. Preserving them depends on the rule you choose and what the new page accepts.
How can you test HTTP redirects with curl?
These commands are templates to adapt to your domains; they do not report a test of a real site. The first sends a GET, displays the headers and discards the response body. It lets you read the initial status and Location without following the redirect.
curl -sS -D - -o /dev/null "https://ancien.example/guide?lang=fr"The second follows redirects with -L, up to five hops, and displays the headers of each response. For the migrated page in this example, look for a single 301 or 308 to the intended destination, followed by a 200 response from the final page. A loop, an unexpected detour or a final 404 needs attention.
curl -sS -L --max-redirs 5 -D - -o /dev/null "https://ancien.example/guide?lang=fr"On Windows with PowerShell, call curl.exe and replace /dev/null with NUL. The -I option requests HEAD: it can be useful, but does not replace a GET check if your infrastructure handles these methods differently. A 200 status alone does not prove the right content is displayed: open the destination as well.
Repeat these checks for HTTP and HTTPS variants, with and without www if they were used, as well as pages receiving external links and URLs with parameters. For a form or API, check the received method and data separately in a test environment with fictional data.
Is a 301 redirect enough to preserve search visibility?
A permanent redirect helps transfer signals to the new URL. It guarantees neither the retention of every ranking nor a reindexing deadline. Google warns that a site move can cause temporary fluctuations. I would prepare the switch using this checklist:
- Check destination pages, their content and their availability before enabling the rules.
- Update internal links and canonical tags to point directly to the new URLs; update hreflang annotations too if the site is multilingual.
- Remove robots.txt or noindex blocks used only to prepare the new site. Keep old URLs crawlable so search engines can see their redirects.
- Verify both sites in Search Console, use its Change of Address tool for the relevant domain change and submit the new sitemap. This tool does not replace redirects.
- Monitor crawl errors, indexed pages and traffic after the switch; fix mappings that lead to missing or unsuitable pages.
How long should you keep redirects and the old domain?
Google recommends keeping redirects for as long as possible, generally at least one year. Keeping them longer can still help visitors following old links or using bookmarks. This is a migration recommendation, not a date when all external links stop existing.
Keep control of the old domain, its renewal and a service able to respond over HTTP and HTTPS. The full old hosting setup can be replaced by a suitable redirect service, provided the mappings and certificates stay operational. Before shutting anything down, take a few URLs from your old links and check the journey through to the final content.
Sources and useful links
- RFC 9110, section 15.4: semantics of 3xx responses (June 2022)
- MDN: 301 Moved Permanently and behaviour after a POST
- MDN: 308 Permanent Redirect, preserving method and body
- MDN: 302 Found, a temporary move
- MDN: 307 Temporary Redirect, preserving method and body
- MDN: 303 See Other and retrieval after a form submission
- Google Search Central: redirects and canonical signals (accessed 22 November 2026)
- Google Search Central: migration with URL changes and keeping redirects (accessed 22 November 2026)
- curl manual: headers, following redirects and hop limits
- Launch checklist: check the site before going live
- Understanding a slow page: measure the stages of the journey