You use redirects to send users and search engines from one URL to another when content moves, changes, or is removed, and choosing the right type affects SEO, user experience, and HTTP behavior.
301 Permanent Redirect: apply this when a page has moved permanently and you want search engines to transfer ranking signals to the new URL. You should update internal links after issuing a 301 to avoid redirect chains. Most browsers and crawlers cache 301s, so use them only when the move is intended to be long-term.
308 Permanent Redirect: use this when you need a permanent redirect that preserves the original HTTP method and request body (for example, keeping POST as POST). You should pick 308 over 301 when client method preservation matters for application correctness.
302 Temporary Redirect: choose 302 when the move is short-lived and you want search engines to keep the original URL indexed. You should use 302 for A/B tests, temporary promotions, or content that will return to the original location.
307 Temporary Redirect: prefer 307 over 302 when a temporary redirect must preserve the request method and body. You should use 307 for temporary API endpoint reroutes where POST or PUT requests must remain unchanged.
Meta refresh and JavaScript redirects: avoid client-side redirects for SEO-sensitive pages because they can be slower and less reliable for crawlers. You should use meta or JS redirects only when server-side control isn’t available, and keep delay to zero seconds if used.
410 Gone and 404 Not Found: return 410 when content is intentionally removed and you want search engines to drop the URL faster; use 404 when the page is missing without an intentional deletion. You should prefer these statuses over redirects when there is no replacement URL.
Special cases and headers: preserve query strings and fragments when required, set appropriate cache-control headers for temporary vs permanent redirects, and use canonical tags to address minor duplicate-content issues without redirecting. You should also avoid redirecting the homepage unnecessarily, which can harm user flow.
Best practices: minimize redirect chains and loops, implement server-side redirects (Apache/Nginx or application-level) for performance, update internal and external links where possible, test redirects with curl or dev tools, and monitor search console or logs to ensure you’re achieving the intended traffic and indexing outcome.