Redirect design is not a matter of memorizing 301 versus 302. Identify the final URL a visitor needs, and combine status codes, Location, internal links, canonical URLs, sitemaps and test evidence into one change plan so search engines, browsers, API clients and caches receive a consistent intent.
The short answer
Use 301 for a permanent move of ordinary pages. Choose 307 or 308 when the method must be preserved.
For a permanent URL change to a company site or article, with no plan to restore the old URL, 301 is the usual choice. For forms, APIs or webhooks that must retain the HTTP method and body after redirecting, consider 307 for a temporary move or 308 for a permanent move. To show a result page with GET after a POST, consider 303; for a temporary destination before returning to the original URL, consider 302.
When a removed page has no equivalent replacement, return 404 or 410 rather than redirecting everything to an unrelated home page. As a practical target, send each old URL directly to its final destination in one hop.
What is a redirect? Its role in SEO and user experience
An HTTP redirect is a response with a 3xx status and a Location header that tells the client to refer to another URL. It is used for URL changes, HTTP-to-HTTPS consolidation, domain moves, temporary moves and navigation after form submission.
In Google Search, 301 and 308 provide a permanent signal that the destination should be considered canonical; 302, 303 and 307 provide a temporary signal that the original URL should remain in search results. Redirects alone do not guarantee rankings or the timing of replacement. Google also considers content equivalence, internal links, canonical URLs, sitemaps, crawling and reprocessing.
Do not substitute redirects for authentication, authorization or error handling
Hiding login requirements, permission failures, missing resources or server errors behind 3xx responses obscures the cause and responsibility. Design authentication responses such as 401 and 403, missing-resource responses such as 404 and 410, and appropriate 5xx maintenance or error responses separately.
Record the reason and end conditions in the change request
Determine whether the move is permanent or temporary, whether the destination is equivalent, whether to preserve the method and query, and who will remove the redirect and when. The status code expresses those decisions.
Compare 301, 302, 303, 307 and 308
Choose by asking whether the move is permanent and whether the same method and body must be used after the redirect. Include login, payment, API, webhook and file-upload flows as well as GET pages.
| Code | Duration | Method after redirect | Main meaning for Google Search | Typical use | Considerations |
|---|---|---|---|---|---|
| 301 | Permanent | Some clients change POST to GET | Signal to consider the destination canonical | Permanent moves of ordinary pages, articles, categories or domains | May be cached. Confirm that there is no plan to restore the old URL. |
| 302 | Temporary | Some clients change POST to GET | Indicates an intent to retain the original URL in search results | Short maintenance or a temporary promotion | Manage the end date, restoration of the original URL and canonical URL. |
| 303 | Temporary | Retrieve the destination with GET or HEAD | Treated as a temporary redirect | A completion or result page after a successful POST | Duplicate submission, retries on failure and visibility of the result URL |
| 307 | Temporary | The method must not be changed | Indicates an intent to retain the original URL in search results | A temporary API, webhook or upload destination change | Test the body, authentication, cookies, signatures, CORS and destination. |
| 308 | Permanent | Preserves method and body | Signal to consider the destination canonical | Permanent API or submission endpoint moves and HTTPS normalization | Check long-lived caches and older client support. |
With 301 and 302, historical client behavior can change a POST to GET. When a method change is unacceptable, choose 307 or 308 and test the clients you actually use.
Which redirect should you choose?
Start with the requirements rather than choosing from a list of codes. Do not treat ordinary GET pages and submission flows as if they were the same.
Common goals and candidate responses
Changing a URL slug
Use 301 if the old and new pages are equivalent and the change is permanent. Update internal links and canonical URLs.
Consolidating HTTP to HTTPS
301 is common for websites. Consider 308 when method preservation must be explicit for APIs, and test every client.
Short maintenance
Use 302 or 307 for a temporary move back to the original URL. For an outage or maintenance response, 503 with Retry-After may be more appropriate.
Completing a form submission
After saving the POST result, send the client to the completion page with 303 to avoid resubmission on refresh.
URL mapping and site moves without SEO surprises
Before implementing a site move, map old URLs to their final destinations. Include externally referenced assets such as images, video, JavaScript, CSS and PDFs. Combine sitemaps, access logs, Search Console, CMS listings and linked URLs to build the inventory.
Collect old URLs comprehensively
Review sitemaps, server logs, analytics, Search Console, CMS publication lists and external links. Include seasonal pages, old campaigns, images and PDFs.
Map each URL to a final destination that serves the same user purpose
Map an article to the same article, a product to its successor and consolidated pages to their combined destination. Return 404 or 410 if no equivalent exists; do not funnel unrelated pages to the home page.
Update search signals on the new site
Align self-referencing canonicals, hreflang, internal links, sitemaps, structured data and OG URLs with the new URLs. Use the mapping to check that signals do not still point at old URLs.
Redirect permanently and directly to the final URL at the server
For permanent moves involving URL changes, use 301 or 308 and send A directly to C rather than through B. Do not duplicate the same rule at multiple layers such as a CDN and web server.
Test every URL before and after launch and monitor Search Console
Record status, Location, final response, key user actions, 404s, 5xx responses and redirect counts. For domain moves, check whether Change of Address applies and submit the new sitemap.
Each hop adds latency and a potential failure point, and makes old rules harder to remove.
Update all entry points, including earlier URLs, to the current final URL.
Causes and fixes for redirect loops and chains
A loop may involve more than one configuration line. If a CDN, load balancer, web server, CMS and application each normalize the scheme, host or path, their decisions can cycle out of sight of visitors. First decide which layer owns the final decision.
Assign one owner for each redirect
Document which layer owns HTTPS, www, trailing slashes and old paths, and do not duplicate the same decision.
Place exact matches and exceptions before broad rules
Evaluate ACME challenges, health checks, admin paths, webhooks and specific retired URLs before directory-wide or host-wide rules.
Check protocol awareness after TLS termination
When TLS terminates at a load balancer, Apache or an application behind it may see HTTP.X-Forwarded-Proto should be trusted only when a controlled proxy overwrites external values and direct access to the backend is restricted.
Detect self-references and cycles in the redirect graph
Treat URLs as vertices and Location values as edges to detect A→A, A→B→A and multiple hops automatically. Test the full mapping, not just sample URLs.
Align the signals for the final URL
If redirect destinations, internal links, canonical URLs, hreflang, sitemaps and structured data point to different URLs, processing can be delayed even when the redirect itself works.
TLS termination and trust in forwarding headers do not agree.
Discard external header values and assign one responsible layer.
Apache, NGINX and PHP redirect examples
Do not paste examples unchanged. Adjust for the canonical host, TLS termination, existing rules, queries and the application's base URL. Record syntax checks, diffs, reloads and immediate recovery commands in the change request.
Apache: prefer Redirect for simple mappings
Place a site-wide HTTP-to-HTTPS redirect in a dedicated port 80 VirtualHost to make ownership clear. Adding unnecessary mod_rewrite rules for simple redirects makes ordering and exceptions harder to understand.
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
Redirect permanent / https://example.com/
</VirtualHost>
For a permanent directory move, check whether the remainder of the original path must be carried to the new path.
Redirect permanent /old/ https://example.com/new/
%{HTTPS} can cause a loop.X-Forwarded-Proto may be used only if a controlled proxy overwrites the header on every request and direct backend access is blocked.NGINX: use return to finish a simple redirect
Define a single-URL redirect narrowly with an exact-match location = and return. Check existing server and location precedence before adding a broad regular-expression rewrite rule.
location = /old-page/ {
return 301 https://example.com/new-page/;
}
server {
listen 80;
server_name example.com www.example.com;
return 308 https://example.com$request_uri;
}
For ordinary web pages, 301 is widely used. Because 308 preserves the method and body, it is a strong candidate when APIs or submission flows are involved; test the actual environment, including older clients.
PHP and CMS: a minimal example when server configuration is unavailable
Limit application-layer redirects to cases that depend on application state or where server settings cannot be changed. Set the header before output and stop execution. Never concatenate unvalidated user input into Location.
<?php
header('Location: https://example.com/new-page/', true, 301);
exit;
How to test redirects with curl, browsers and logs
A browser may reach the final page while an intermediate 302 or chain is present, POST becomes GET, or credentials are at risk of being sent to another host. Save the initial response, all hops, final state, user actions and logs separately.
Check the initial response and Location with GET
curl -I sends a HEAD request, which may not behave like GET. Also obtain response headers from a GET while discarding its body.
curl -sS -D - -o /dev/null \
'https://old.example.com/path?ref=test'
Check every hop, the final URL and the redirect count
curl -sS -L --max-redirs 10 -o /dev/null \
-w 'final_url=%{url_effective}\nstatus=%{http_code}\nredirects=%{num_redirects}\n' \
'https://old.example.com/path'
As a rule, expect one redirect, the mapped final URL and a successful final response such as 200. If the maximum redirect count is reached, investigate loops, cycles or unnecessary normalization.
Use staging and test credentials for POST and API tests
curl -sS -v -L --max-redirs 5 \
-H 'Content-Type: application/json' \
--data '{"test":true}' \
'https://staging.example.com/old-endpoint'
When curl follows a POST with -L, it normally changes to GET after 301, 302 and 303, but resends the same method after 307 and 308.--post301 can force different behavior, but that is a client setting and does not replace selecting an appropriate server status code.
Status, Location, Cache-Control, Vary, cookies, canonical host, encoding and query string.
Chrome, Edge, Safari, back, refresh, bookmarks, login, forms, payments and downloads.
Method, body, Content-Type, Authorization, cookies, signatures, CORS, timeouts and retries.
Every mapping row, 3xx, 404, 5xx, external hosts, hop counts, Search Console and sitemaps.
--location-trusted should not be used casually. It can send credentials or cookies across redirected hosts, so use it only when you fully control the test and every destination.Removing redirects, rollback and caches
For a temporary redirect, set its end time and owner at the start. Permanent redirects also need a recovery plan that can restore the configuration, internal links and search signals together after an error or unexpected effect.
Preserve evidence and stop further changes
Record the time, URL, every status and Location, response headers, browser, logs and the preceding diff. Do not layer on another redirect before understanding the cause.
Restore the responsible layer to a known state
Disable the new rule at the CDN, load balancer, web server or application layer that owns the decision, and reload after checking syntax.
Invalidate only affected cache entries
Avoid purging the entire CDN; target affected URLs. Since a server cannot fully clear a browser's cached 301 or 308, also test a fresh profile, a private window and unused URLs.
Restore internal links and search signals to the same recovery version
If canonical, hreflang, sitemaps, structured data or internal links changed, restore them with the redirect as one change.
Retest using the same URL map and test cases
Recheck the first response, all hops, final status, GET, POST and API flows, key actions and logs. Record the cause, impact, remaining caches and prevention steps.
Redirect checklist before and after launch
Completion means another person can reproduce the results; merely opening the page in a browser is not enough.
Design
- A reason, permanence, end conditions and owner are recorded.
- Each old URL maps to a final URL or 404/410.
- Method, body, query, cookie and credential handling are defined.
- Exceptions, rule order, responsible layers and recovery configuration are documented.
- The new URL serves the purpose of the old URL.
Implementation
- Each old URL reaches its final URL in one hop where practical.
- Exact matches and exceptions are evaluated before broad rules.
- CDN and web-server rules are not duplicated.
- External input is not concatenated directly into Location.
- Syntax checks, diffs, reloads and recovery commands are saved.
Verification
- The initial status and Location were checked with GET.
- All hops, the final URL, status and redirect count were recorded.
- POST, API and webhook methods and bodies were tested safely.
- Key actions were checked in Chrome, Edge, Safari and mobile.
- Logs show no loops, unintended external redirects, 404s or 5xx responses.
SEO and postlaunch
- Internal links, canonical, hreflang and structured data were updated.
- The new sitemap was submitted and old URLs are monitored.
- Search Console procedures for a domain move were checked.
- Temporary redirects have an end date and permanent redirects have an owner.
- Redirects can generally be retained for at least one year, or longer if needed.
Primary sources and update policy as of July 29, 2026
HTTP specifications, search engines, web servers and test tools change. Check the official documentation and configuration-validation commands for your deployed versions as well. We reviewed the following on July 29, 2026.
Google Search Central
- Redirects and Google Search: describes 301/308 as permanent and 302/303/307 as temporary signals.
- Site moves with URL changes: covers URL mapping, direct redirects, canonical URLs, internal links, sitemaps, monitoring and retention.
HTTP standard
- RFC 9110: HTTP Semantics / Redirection: covers 301, 302, 303, 307 and 308 semantics, methods and cacheability.
Web servers
- Apache HTTP Server: Redirecting and Remapping: covers when to prefer Redirect, TLS termination, trust in X-Forwarded-Proto and exceptions.
- NGINX: ngx_http_rewrite_module: covers return syntax, supported status codes and processing order.
Testing tool
- curl manual: covers --location, --max-redirs and POST behavior after 301/302/303 versus 307/308.

Finite Field editorial policyWe prioritize Google Search Central for search behavior, RFCs for status-code semantics, each web server's official documentation for configuration and the curl manual for test behavior. When an interface or specification changes, we update the review date and text.
Frequently asked questions about redirects
Should I use 301 or 308?
Both signal a permanent move. 301 is widely used for ordinary GET pages. If POST, API or webhook requests must retain the method and body after redirecting, consider 308 and test your clients.
Is the difference between 302 and 307 about security?
No. Both are temporary redirects, but a client must not change the method when automatically following 307. Some clients change POST to GET after 302, so verify the requirements for submission flows.
When should I use 303?
Use it in Post/Redirect/Get after a form or order POST to retrieve a result page with GET. This helps prevent duplicate submissions on refresh; success, failure and retry handling still need separate design.
Can all removed pages redirect to the home page?
Do not redirect them all when no equivalent replacement exists. A destination that does not match the user's purpose can confuse visitors and may be treated as a soft 404 by Google. Return 404 or 410 when there is no replacement, and offer search or relevant links on the error page.
How many redirects can a chain contain?
Prefer one hop from the old URL to the final destination. Googlebot can follow multiple hops, but Google recommends direct redirects and advises keeping unavoidable chains ideally to three or fewer and fewer than five.
How long should 301 or 308 redirects remain after a site move?
Google generally advises keeping them for at least one year. For permanent moves, keeping them as long as practical is safer for external links, bookmarks and older documents.
Is a successful curl -I enough to finish testing?
No. -I sends HEAD, which may not match GET or POST behavior. As appropriate, check the first response, every hop, final response, GET, POST and APIs, authentication, cookies, key browser actions and logs.
Does removing a 301 immediately restore the old URL?
Browsers or intermediate caches may retain a 301 or 308, so a visitor may continue to see the old redirect after the server setting is reverted. Restore the owning layer's rules, CDN cache, internal links, canonical, hreflang and sitemap to the same recovery version, then retest in a new session.
Good redirects depend on mapping and testing, not just a status code
Decide permanence, method and body preservation, and whether the final URL serves the same purpose. Redirect old URLs directly to their final destinations and align internal links, canonical, hreflang and sitemaps. Test GET and POST separately before launch, then monitor logs and Search Console.
Assign an end date for temporary redirects and an owner and recovery path for permanent ones. Because 301 and 308 effects can persist in caches and search processing, include limited testing and rollback rather than assuming a change can simply be undone later.