Redirect 301 vs 302
A 301 redirect tells browsers and search engines that a URL has moved permanently, while 302 means a temporary move. Both send visitors elsewhere, but browser caching and crawler signal handling differ.
The main difference
| Aspect | 301 | 302 |
|---|---|---|
| Nature | Permanent | Temporary |
| Browser cache | Strong, can persist for a long time | Usually weaker than 301 |
| SEO signal | Passed to the target URL | Source URL is treated as still valid |
| When to use | Domain change, URL restructure | A/B test, maintenance, seasonal promo |
There are also 307 and 308: both preserve the HTTP method (POST stays POST), while 301/302 historically could change the method in some clients. For ordinary websites, 301 and 302 are enough; for APIs, use 307/308 when the method must be preserved.
How to set a redirect
In cPanel, open Domains → Redirects, choose the domain, fill in the source path and target URL, then pick the type. On Apache, an .htaccess rule looks like:
Redirect 301 /old-page https://example.com/new-page
In WordPress, a redirect plugin helps, but make sure rules from plugins, themes, and .htaccess do not stack. One URL should be handled by one rule.
What to watch for
- Avoid redirect chains. A → B → C slows loading and confuses crawlers. Point directly at the final target.
- Do not use 302 for a permanent change. You can lose SEO signals and forget to update it.
- Keep HTTPS and www redirects consistent. Choose one canonical version, then point the rest at it.
- Test with
curl -I. Confirm the status andLocationheader before deploying.
FAQ
Can a 301 be undone?
On the server, yes, but visitors who already cached it may keep opening the old target until their cache expires. Test redirects on staging before applying them.
When should I use a 302?
When the source URL really will return, such as a maintenance page, a seasonal campaign, or a test of a new page.
Do redirects affect speed?
One redirect adds one HTTP round trip. Long chains can add hundreds of milliseconds, especially on mobile connections.
Disclaimer: Hosting Wiki articles are prepared for educational and reference purposes. Hosting technology keeps evolving, so some technical details may change over time.