When you move a web address to another address, a redirect is used so visitors and search engines find the new address. The two most common types are 301 and 302 — and knowing the difference between them is critical for both user experience and SEO. This guide explains server-side redirects.
Related reading: .htaccess guide · Virtual host configuration
What Is a Redirect?
A redirect is the act of sending a visitor or a search engine bot from the URL they requested to a different URL. If a redirect is defined for the requested page, the server returns an HTTP status code and the new address to the browser; the browser then automatically goes to the new address.
The Difference Between 301 and 302
| Property | 301 — Permanent | 302 — Temporary |
|---|---|---|
| Meaning | The page has moved permanently | The page is temporarily elsewhere |
| SEO signal | Ranking value transfers to the new URL | The old URL stays in the index |
| Browser cache | Strongly cached | Not cached, or briefly |
| Use | Permanent move, domain change | Maintenance, A/B test, temporary campaign |
In short: if content has moved permanently to a new address, use a 301. If content is only being redirected temporarily elsewhere, use a 302.
The SEO Impact of Redirects
The redirect type directly affects your search rankings. A 301 transfers most of the ranking value the old page accumulated (including link value) to the new page — which is why it is the correct choice for permanent moves.
If you mistakenly use a 302 for a permanent move, the search engine keeps the old URL in the index and ranking value is not transferred. Doing a permanent move with a 302 is a common and costly mistake.
Redirects in Nginx and Apache
In Nginx, a permanent redirect is defined with a single line:
# A 301 redirect for a single page
location = /old-page {
return 301 /new-page;
}
# Moving an entire domain to a new address
server {
server_name old-domain.com;
return 301 https://new-domain.com$request_uri;
}
In Apache, the same job is done by Redirect 301 or RewriteRule rules in the .htaccess file. You can see our .htaccess guide where we cover redirect rules.
Avoid Redirect Chains
Frequently Asked Questions
Should an HTTP-to-HTTPS redirect be a 301?
Yes. The move to HTTPS is a permanent change; use a 301. This way search engines accept the HTTPS version as the permanent address.
Should I do the redirect on the server or in the application?
Doing it at the server level (Nginx/Apache) is faster — the request is answered before it ever reaches the application. If the redirect depends on application logic, it can be done in the application too.
What is a 307 redirect?
A 307 is a temporary redirect similar to a 302; the difference is its guarantee to preserve the request's HTTP method (for example POST). For most simple scenarios, 301 and 302 are enough.
Plan your site migration and redirect strategy without ranking loss with the KEYDAL SEO team. Explore KEYDAL SEO services