In short
- Use 301 or 308 for permanent moves and 302 or 307 for temporary situations. Google treats a permanent redirect as a strong signal that the new URL is the canonical one, and a temporary redirect as a weak signal.
- Unlike 301 and 302, 307 and 308 preserve the request method and body; when moving pages, there is no difference between 301 and 308 for Google.
- Send every old URL to its final URL in a single step. Googlebot follows at most 10 redirect hops.
- Don't redirect removed pages to the homepage in bulk; if no page covers the same content, return 404 or 410.
- When migrating a site, keep the redirects in place for at least a year; Google's site move documentation recommends this.
What do 301, 302, 307 and 308 mean?
A redirect response has two parts: a status code starting with 3 and a Location header carrying the target URL. When the browser receives this response, it requests the target URL itself; most of the time the visitor doesn't notice anything.
HTTP/1.1 301 Moved Permanently
Location: https://ornek-site.com/yeni-sayfa
The four common codes answer two questions: is the move permanent, and should the browser use the same method (for example the POST of a form submission) in the second request?
| Code | Meaning | What does the browser do? | What does Google do? |
|---|---|---|---|
301 Moved Permanently | Permanent move | May cache the response; may turn a POST request into GET. | Strong signal that the target is the canonical URL; the old URL drops out of the index over time. |
302 Found | Temporary redirect | Doesn't cache it unless headers say otherwise; may turn POST into GET. | Weak signal; the old URL may stay in the index. |
307 Temporary Redirect | Temporary, method preserved | Repeats the request with the same method and body. | Treats it like 302. |
308 Permanent Redirect | Permanent, method preserved | May cache it; method and body are preserved. | Treats it like 301. |
303 See Other is used to send visitors to a result page after a form submission; Google treats it as temporary too.
Browser cache: why is a wrong 301 hard to undo?
The HTTP standard (RFC 9110) says 301 and 308 responses may be stored even without an explicit cache header, and browsers keep them for a long time. Even if you remove a 301 published by mistake from the server, the browsers of users who visited the URL before may keep going to the old target. Try a new rule with 302 first and switch it to 301 once it works; run your tests in a private window.
What is Chrome's “307 Internal Redirect”?
If developer tools show your http:// URL going to the https:// URL with a 307, it usually isn't your server's response. Because your site sent an HSTS header earlier, the browser upgrades the request itself before it reaches the server and shows this as a 307. To see what the server actually returns, test the URL with a tool that has no browser cache, such as the Redirect checker.
Which redirect should you use, and when?
- A page, folder or domain has moved permanently: 301. This covers every case where you change your URL structure, merge two pages, or move from http to https or to a new domain.
- A form or API URL has moved: 308. Data sent with POST is passed on to the new URL unchanged; with 301, some clients turn the request into GET and drop the data.
- A temporary campaign or login: 302 or 307; the original URL should stay in the index.
- A/B test: for experiments that redirect visitors to a test version, Google recommends using 302 rather than 301 and removing the redirect when the test ends.
- Maintenance or a temporary outage: not a redirect but a
503 Service Unavailableresponse with an optionalRetry-Afterheader. According to Google's documentation, Googlebot retries later when it sees a 503. - A removed page: 301 to a page that covers the same content if there is one; otherwise 404 or 410. Details below.
- Redirecting by language or country: don't redirect visitors automatically based on their IP address or browser language; Googlebot mostly crawls from the US and without sending a language preference. Show a language suggestion and link the versions with hreflang (hreflang guide).
Site migrations, domain changes, HTTPS and www
For migrations where URLs change, Google's site move documentation asks for every old URL to go to the most suitable new URL with a server-side permanent redirect. The steps are:
- List the old URLs. Combine the URLs in your sitemap, in Search Console's performance report and those that other sites link to. Site crawl and Backlink analysis help you complete the list.
- Prepare a mapping table. Next to each old URL, write the new URL that best covers its content; the ones without a match will return 404 or 410.
- Write the rules and test them in a staging environment first. Paste the mapping table into the Redirect rule generator to get rules for your server and warnings about chains.
- Point everything on the new site to the final URLs. Internal links, canonical and hreflang tags, the sitemap and the URLs in structured data shouldn't point to an old URL or to a redirect.
- Launch the migration and test the old URLs right away. They should all return a single-step 301, and the final URLs should return 200.
- Monitor Search Console. Submit the new sitemap and keep an eye on redirect errors and 404s in the Page indexing report. Some fluctuation in traffic for a while is normal.
- Don't remove the redirects. Google recommends keeping redirects in place for as long as possible, generally at least a year; if other sites link to the old URLs, keeping them longer does no harm.
Don't block the old URLs with robots.txt. Googlebot only sees a redirect if it can crawl the old URL; the signals of a blocked URL aren't passed on to the new one.
Domain change
When moving to a new domain, redirect every URL on the old domain to its counterpart on the new domain, keeping the path; don't send them all to the new homepage. Then verify both domains in Search Console and use the Change of Address tool in the old property. Keep renewing the old domain's registration; an expired domain can end up in someone else's hands together with the links it has earned.
Moving from http to https, and HSTS
After installing the certificate, redirect every http:// request to the https:// version of the same path with a 301. This is a protocol change and doesn't require the Change of Address tool, but add the https:// property to Search Console separately or use a domain property that covers both protocols. Once the redirect is in place, add the HSTS header:
Strict-Transport-Security: max-age=31536000; includeSubDomains
HSTS tells the browser to open the site only over HTTPS for a set period. If you aren't sure all your subdomains support HTTPS, don't add includeSubDomains and start with a short max-age; because browsers store the value, undoing HSTS is even harder than undoing a 301.
With or without www, with or without a trailing slash?
For search engines there's no difference; what matters is choosing one. The http:// and https:// versions of the www and non-www hostnames should all go to a single URL in a single step. The same applies to the trailing slash: if /hizmetler and /hizmetler/ both return 200, the same content is published at two URLs. Choose one and redirect the other to it with a 301; use the chosen form in the canonical tag, the sitemap and internal links as well.
Generate Apache, Nginx, Vercel, Netlify and Cloudflare rules from your list of old and new URLs in one go.
Redirect rule generatorExamples for Nginx, Apache, Cloudflare, Vercel, Netlify and WordPress
The examples assume the preferred URL is https://ornek-site.com without www; test the result after every change.
Nginx
Handle http:// and www requests in separate server blocks and send them to the preferred URL in a single step. Only the preferred hostname should remain on the server_name line of the main block:
server {
listen 80;
listen [::]:80;
server_name ornek-site.com www.ornek-site.com;
return 301 https://ornek-site.com$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name www.ornek-site.com;
ssl_certificate /etc/letsencrypt/live/ornek-site.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ornek-site.com/privkey.pem;
return 301 https://ornek-site.com$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name ornek-site.com;
ssl_certificate /etc/letsencrypt/live/ornek-site.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ornek-site.com/privkey.pem;
location = /eski-sayfa { return 301 /yeni-sayfa; }
rewrite ^/blog/(.*)$ /yazilar/$1 permanent;
}
$request_uri carries the path and query string together; permanent means 301. After the change, test the configuration with nginx -t and, if there are no errors, reload it with nginx -s reload.
Apache (.htaccess)
On shared hosting, the rules go in the .htaccess file in the site's root directory and require mod_rewrite. The first rule sends http:// and www requests to the preferred URL in a single step:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://ornek-site.com%{REQUEST_URI} [R=301,L,NE]
RewriteRule ^eski-sayfa\.html$ /yeni-sayfa [R=301,L]
RewriteRule ^blog/(.*)$ /yazilar/$1 [R=301,L]
If your server sits behind a CDN or a load balancer, %{HTTPS} may appear as off on every request and cause a loop; in that case, write the condition as %{HTTP:X-Forwarded-Proto} !https.
If you use WordPress, add the rules above the # BEGIN WordPress line. Don't mix Redirect and RewriteRule directives in the same file: they're handled by different modules in a different order and produce unexpected results.
Cloudflare
In Cloudflare, http:// requests are redirected by the “Always Use HTTPS” setting under SSL/TLS › Edge Certificates. To go from the www URL to the non-www URL, create a single rule (Single Redirect) in the Redirect Rules section under Rules. The condition expression and dynamic target are as follows; choose 301 as the status code and turn on “Preserve query string”:
(http.host eq "www.ornek-site.com")
concat("https://ornek-site.com", http.request.uri.path)
For many individual URLs, upload a CSV in the Bulk Redirects section. Don't leave the SSL/TLS encryption mode on “Flexible”: in this mode Cloudflare connects to your server over http://, and if your server redirects the request to https://, a loop forms. Use “Full (strict)”.
Vercel and Netlify
In Vercel, redirects go in the redirects array of the vercel.json file. Note: "permanent": true returns 308 and false returns 307; if you specifically want 301 or 302, use the statusCode field.
{
"redirects": [
{ "source": "/eski-sayfa", "destination": "/yeni-sayfa", "permanent": true },
{ "source": "/blog/:slug", "destination": "/yazilar/:slug", "statusCode": 301 }
]
}
Vercel redirects http:// requests to HTTPS by itself; the www redirect is set up under Settings › Domains. In Netlify, rules are written line by line in the _redirects file at the root of the publish folder, and 301 is used when no code is given:
/eski-sayfa /yeni-sayfa 301
/blog/* /yazilar/:splat 301
/kampanya /firsatlar 301!
The exclamation mark at the end forces the redirect even if a file still exists at the old URL.
WordPress
WordPress builds URLs from the “WordPress Address (URL)” and “Site Address (URL)” fields on the Settings › General screen and corrects www forms that don't match them with a 301 by itself. When moving to https, update these two fields first, then refresh the old http:// links in the database with a search-and-replace tool.
When you change a post's slug, WordPress sends the old URL to the new one with a 301; it doesn't do this for pages or category URLs. Use a redirect plugin or a server rule for those, but don't define the same redirect in two places.
Redirect chains and loops
A chain is when a URL reaches its final target in more than one step. In the example below, a single visit means four requests:
http://www.ornek-site.com/urun
→ 301 https://www.ornek-site.com/urun
→ 301 https://ornek-site.com/urun
→ 301 https://ornek-site.com/urunler/deri-canta
→ 200
Every step is a separate request and a delay. Googlebot follows a chain for at most 10 steps, and if it can't reach the end, Search Console shows a redirect error.
How do chains form, and how do you shorten them?
- Layered rules. When the HTTPS, www and page rules run separately, each adds a step. Combine the HTTPS and www conditions into a single rule as in the Apache example, and write the final URL as the target in page rules.
- Stacked migrations. For a page that moved first from A to B and then from B to C, point A straight to C as well. The “Shorten chains” option in the redirect rule generator does this for your list automatically.
- Different layers doing the same job. If the CDN, the server and the application each perform the same www redirect, the steps add up. Keep each redirect in a single layer.
- Internal links to old URLs. A link to a redirected URL adds an extra step on every click. Update links to the final URL; Link analysis lists redirecting links.
Loops
In a loop, A goes to B and B goes back to A. The browser shows a “too many redirects” error (ERR_TOO_MANY_REDIRECTS in Chrome) and the page doesn't open. Common causes: Cloudflare's “Flexible” mode clashing with an HTTPS rule on the server, the HTTPS condition always appearing off behind a CDN, WordPress and a server rule preferring different www forms, and two opposing rules that change the trailing slash. Trace the chain step by step: the step that returns to a URL already seen points to the layer causing the problem.
Meta refresh and JavaScript redirects
If you don't have access to the server settings, you can redirect from within the page. According to Google's redirect documentation:
- An instant meta refresh (0 seconds) is interpreted as a permanent redirect.
- A delayed meta refresh (for example 5 seconds) counts as a temporary redirect.
- A JavaScript redirect is only seen when Google renders the page and runs the script; if rendering fails, the redirect may go unnoticed altogether. Google recommends it only when a server-side redirect or a meta refresh isn't possible.
<meta http-equiv="refresh" content="0; url=https://ornek-site.com/yeni-sayfa">
<script>
window.location.replace("https://ornek-site.com/yeni-sayfa");
</script>
location.replace doesn't add the old page to the browser history; visitors who press the back button don't get caught in the redirect again. Put the meta refresh at the top of the <head> section. With both methods the browser downloads the old page first, so they're always slower than a server-side 301, and some bots don't follow them at all.
The Redirect checker also follows a meta refresh and the Refresh header on the final page as a step and shows the delay. It doesn't follow JavaScript redirects; check those by opening the page in a browser.
Removed pages: 404, 410 and soft 404
When you remove a page, you have three options: a 301 to a page that covers the same content, 404 Not Found or 410 Gone. According to Google's documentation, all 4xx codes except 429 are handled the same way: the content is treated as nonexistent and the URL drops out of the index over time. Because 410 says “permanently removed”, it states your intent more clearly.
What is a soft 404?
A soft 404 is a response that says the page doesn't exist but returns a 200 status code: an empty category saying “Product not found”, or a post whose content was deleted but whose template remains. Google flags these URLs as “Soft 404” in Search Console's Page indexing report and doesn't index them. Sending many removed pages to the homepage or an unrelated category in bulk can have the same result: Google may treat these irrelevant redirects as soft 404s.
Redirect, or return a 404?
- A product was discontinued and replaced by a new model: 301 to the new model.
- A product is temporarily out of stock: keep the page live with a 200 and state the stock status; don't redirect.
- A campaign ended and has no equivalent: return 410.
- Two posts were merged: 301 from the old post to the merged one.
- Error page: your site's 404 page must actually return a 404 code; error pages that return 200 or redirect to the homepage create soft 404s.
To see your own error page's code, test a URL that doesn't exist (for example /olmayan-sayfa-123) with the Bulk status code checker.
Canonical or redirect?
Both say “this is the main URL”, but they work differently. A redirect removes the old URL: users and bots alike go to the new one. rel="canonical", on the other hand, leaves both pages accessible and suggests to the search engine which one it should index. Canonical is a suggestion: if it conflicts with other signals, Google may choose a different URL.
- If the old URL doesn't need to stay accessible (migration, merger, domain change): redirect.
- If both URLs need to stay accessible (filter and tracking parameters, content republished on another site): canonical.
- Language or country versions: neither. Each version declares itself as canonical, and the versions are linked to each other with hreflang.
When using both together, don't create conflicts: the canonical tag shouldn't point to a redirected URL, and the target of a redirect shouldn't declare another page as canonical. You can check canonical tags with the Meta tag checker and find the details in the meta tags guide.
See every redirect step, status code and http/www version of a URL in one report.
Redirect checkerCheck your redirects step by step
After publishing the rules, go through them in this order:
- Test the domain versions. Enter your domain in the Redirect checker. The tool traces the chain step by step and tests the http://, https://, www and non-www homepages separately. You should see “All versions lead to a single URL”; a warning such as “The http:// version doesn't redirect to HTTPS” shows that your rule is incomplete.
- Trace important old URLs one by one. Each of the old pages with the most traffic should return a single-step permanent redirect; fix any temporary redirect, multi-step chain or failing final URL findings. Choose Googlebot (smartphone) as the user agent to also catch rules that behave differently for bots.
- Test the whole list in bulk. Paste the old URLs from the mapping table into the Bulk status code checker; it checks up to 100 URLs at a time. In the 3xx tab, every URL's chain should be 301 → 200; in the 4xx and 5xx tabs, no URLs should remain other than pages you know have no equivalent. Download the result as CSV and compare it with your mapping table.
- Test the new URLs too. URLs in the sitemap should return 200 directly. The Sitemap validator tests the status code and redirects of URLs it picks at random from the sitemap.
- Verify from the command line if needed. To see the raw response for a single URL, use the command below;
-Irequests only the headers,-Lfollows redirects and shows the status code andLocationheader of each step in order.
curl -sIL http://ornek-site.com/eski-sayfa
Checklist
- 301 or 308 is used for permanent moves, and 302 or 307 for temporary situations.
- Every old URL goes to its final URL in a single step, and the final URL returns 200.
- The http://, https://, www and non-www versions all go to a single URL.
- Removed pages weren't funneled to the homepage; those without an equivalent return 404 or 410.
- Internal links, canonical and hreflang tags, and the sitemap point to the final URLs.
- The old URLs aren't blocked by robots.txt.
- The redirects will stay in place for at least a year, and the old domain's registration is being renewed.
Frequently asked questions
Does a 301 redirect hurt rankings?
A correctly set up 301 passes the old URL's signals on to the new URL. Short-term fluctuation after a migration is normal; common causes of lasting losses are wrong targets, long chains and redirecting pages to the homepage in bulk.
Is it a problem to use 301 instead of 308?
Not when moving pages: Google treats both as permanent redirects. The difference lies in the request method: 308 carries a POST request and its body to the new URL unchanged, while with 301 the browser may turn the request into GET. Use 308 for form and API URLs and 301 for pages.
How long should I keep redirects?
Google's site move documentation recommends as long as possible, generally at least a year. If other sites have linked to your old URL, leaving the redirect in place indefinitely is the safest option.
Should I redirect deleted pages to the homepage?
No. Google may treat bulk redirects to an unrelated page, especially the homepage, as soft 404s. If a page covers the same content, redirect to it with a 301; otherwise return 404 or 410.
How do I fix a redirect loop?
Trace the chain step by step and find which step returns to a URL already visited. The most common causes are Cloudflare's Flexible SSL mode, a wrongly written HTTPS condition behind a CDN, and WordPress and the server preferring different www forms. Keep each redirect in a single layer.
Are JavaScript redirects OK for SEO?
Only as a last resort. Google sees a JavaScript redirect only after rendering the page, and that doesn't always succeed. If you can't set up a server-side 301, try a 0-second meta refresh first; Google interprets it as a permanent redirect.
Related guides and tools
- Redirect checker: traces a URL's chain and domain versions step by step.
- Bulk status code checker: shows the status code, chain and final URL of up to 100 URLs at once.
- Redirect rule generator: generates Apache, Nginx, Vercel, Netlify and Cloudflare rules from a list of old and new URLs.
- HTTP header checker: shows the
Location, HSTS and cache headers. - SSL certificate checker: before moving to https, make sure the certificate covers both the www and non-www hostnames.
- Hreflang and multilingual SEO guide: link your language versions correctly.
- XML sitemap guide: list only final URLs in your sitemap.
- Technical SEO checklist: audit your other server-level settings.
- SEO guides: all the guides on Röntgen.