SEO & Digital Marketing Published: · Last updated: · 12 dk okuma 14

How to Set Up 301 Redirects and Avoid SEO Loss During a Site Migration

Kerem Emre Örer
Kerem Emre Örer
Netivis SEO ve içerik ekibi
Masada açık dizüstü bilgisayar, saksı bitkisi ve kahve fincanı; site taşırken 301 yönlendirme yapmak

In brief

301 yönlendirme, bir sayfanın adresinin kalıcı olarak değiştiğini hem ziyaretçiye hem arama motoruna bildiren sunucu yanıtıdır. Apache'de .htaccess dosyasıyla, Nginx'te return 301 ile yapılır. Doğru kurulan yönlendirme site taşımada SEO kaybını azaltmaya yardımcı olur.

A 301 redirect is a server response that tells both visitors and search engines that a page's address has changed permanently. On an Apache server you add a Redirect permanent or RewriteRule ... [R=301,L] line to the .htaccess file; on Nginx you use return 301. If you redirect from the old URL to the new one directly, in a single hop and to the relevant page, you keep SEO loss during a migration to a minimum.

In this guide you'll first see how Google interprets redirect types, then working examples for three different server environments and the steps to follow during a site migration. At the end, we've added the most common mistakes seen in migration projects and how to check for them.

What is a 301 redirect and when do you need one?

301 is the HTTP status code meaning "moved permanently." When a browser or Googlebot requests the old address, the server returns the new address instead of the content, and the client moves on to it.

You need a 301 in these cases:

  • When your domain name changes (moving from oldbrand.com to newbrand.com).
  • When you move from HTTP to HTTPS, or from the www to the non-www version.
  • When a page URL changes (slug edits, folder structure changes, a CMS switch).
  • When two or more similar pages are merged into a single stronger page.

If a page is only temporarily moved elsewhere (for maintenance or a campaign, for example), a temporary redirect is used instead of a 301. We explain this distinction in the next section.

Web administrator reviewing a URL list on a laptop before a site migration

Is there a difference between 301, 302, 307 and 308?

Yes; Google groups these codes into two categories. According to Google's redirect documentation, permanent redirects make search results show the new target address, while temporary redirects keep showing the source page (Google Search Central: Redirects and Google Search).

CodeMeaningHow Google treats it
301Moved permanentlyPermanent: the new address is shown
308Permanent redirectPermanent: the new address is shown
302Temporary (found)Temporary: the source page is shown
307Temporary redirectTemporary: the source page is shown

According to the same documentation, Google treats instant (0-second) meta refresh redirects as permanent and delayed ones as temporary. JavaScript redirects are recommended only if you can't do a server-side redirect, because if an error occurs while the page is being rendered, Google may never see the redirect.

Our recommendation: If the move is not going to be reversed, use a server-side 301. Keep meta refresh or JavaScript as a last resort for cases where you can't access the server configuration.

How do you set up a 301 redirect with .htaccess?

If you use Apache-based hosting (common with panels such as cPanel and Plesk), you write the redirect in the .htaccess file in the site's root directory. Google's documentation also gives examples of two methods: mod_alias and mod_rewrite.

For a single page: Redirect permanent

If you're moving a single address, this is the simplest method. According to the Apache documentation, if no status code is specified the redirect is temporary (302); permanent returns a 301 (Apache mod_alias documentation).

Redirect permanent /eski-sayfa https://www.ornek.com/yeni-sayfa

Pattern-based bulk redirects: RewriteRule

To move dozens of similar addresses with a single rule, use mod_rewrite. For example, to move the /blog-eski/ folder under /blog/:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^blog-eski/(.*)$ https://www.ornek.com/blog/$1 [R=301,L]
</IfModule>

Here R=301 specifies the permanent redirect code, and L means no further rules are processed after this one.

HTTP to HTTPS and to www in one step

A single rule is enough to consolidate version differences (http/https, www/non-www) into one address. The example below should be adapted to your domain name and preferred version:

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.ornek.com/$1 [R=301,L]

This rule sends both HTTP requests and non-www requests to https://www.ornek.com in a single step, so you avoid two separate redirects running back to back (a chain).

If you'd like to generate ready-made rules, you can use Netivis's free Htaccess tool; still, check the output against your own domain name before adding it to the file.

Image suggestion: the edit screen of the .htaccess file in cPanel File Manager (a screenshot with the domain name and user details hidden).

How do you write a 301 in Nginx and PHP?

If you use Nginx, return 301 in the format Google gives as an example is enough:

location = /eski-sayfa {
    return 301 $scheme://www.ornek.com/yeni-sayfa;
}

If you can't access the server settings but have a page running on PHP, you can also redirect with a response header. Google's documentation gives an example of this method too:

<?php
header('HTTP/1.1 301 Moved Permanently');
header('Location: https://www.ornek.com/yeni-sayfa');
exit;

If you use a CMS such as WordPress, redirect plugins do the same job. Whichever method you choose, you need to test that the response code really is 301; we cover that below.

In what order should 301 redirects be set up during a site migration?

Google's "site move" guide defines five main steps: general best practices, preparing the new site, building the URL mapping list, setting up redirects from the old addresses to the new ones, and monitoring traffic (Google Search Central: How to move a site). You can translate that into practice like this:

  1. Export the old site's URL list. Put all addresses into a table from the sitemap, a crawling tool or Search Console data; also flag the pages that receive backlinks.
  2. Map every old address to a new one. The table should have two columns: old URL, new URL. Write the ones with no equivalent in a separate list.
  3. Prepare and test the new site. For content that has been deleted or not merged, make sure the new site returns a 404 or 410 response.
  4. Set up the redirects. Google recommends server-side permanent redirects (301 and 308).
  5. Submit the new sitemap to Search Console. Both the old and new sites (including all variants, www and non-www) must be verified in Search Console. If the domain name or subdomain is changing, the Change of Address tool is used for the old site; it isn't needed for an HTTP to HTTPS or www/non-www move, or for a path change within the same domain.
  6. Monitor. Track the indexing of the new addresses with the sitemap and index coverage reports.

Set your expectations correctly from the start: Google considers temporary fluctuations in rankings during a move to be normal. According to Google's site move guide, for a medium-sized site it can take a few weeks or longer for the new addresses to replace the old ones; for large sites it takes even longer.

If you're doing this move as part of a website redesign project, preparing the redirect map during the design phase makes the work much easier. If you're planning the budget for the new site, also take a look at what website development costs depend on.

Cables and network devices in a server room; server-side redirects after a site migration

How long should redirects stay in place?

Google recommends keeping redirects in place for as long as possible, generally at least 1 year, and adds that you may also consider keeping them indefinitely for users' sake.

This has a cost as well: redirects slow users down. That's why you should update the internal links on your own site and the external links that bring traffic to the new address.

What are the most common 301 redirect mistakes?

Redirect chains

If old address A redirects to B and B redirects to C, you have a chain. Google recommends avoiding chains and ideally not exceeding 3, and in any case not exceeding 5; Googlebot follows at most 10 hops.

The fix is simple: redirect A directly to C. Each time you update your migration table, review the old rules as well.

Redirecting everything to the homepage

Google advises against redirecting many old addresses to a single irrelevant target such as the homepage; this confuses users and can be treated as a soft 404.

If a page has no direct equivalent, target the page closest in topic or return a 404/410. If you've merged several pages into one, redirecting all of them to that page is correct.

The wrong status code

If you forget to write permanent in an Apache Redirect line, the redirect becomes temporary. In that case Google may keep showing the old address in search results. After adding the rule, always verify the response code.

Removing redirects too early

It's tempting to delete the rules a few weeks after the move is finished. But Google's recommendation is at least 1 year, and there may be external links and bookmarks that still use the old addresses.

A redirect is a safety net, not a permanent solution. The links in your menu, content and sitemap should point directly to the new address. In this respect, internal link structure is also one of the first steps of the technical work in our monthly SEO service.

How do you test that redirects work correctly?

Three simple checks catch most mistakes:

  1. See the response code. In a terminal, the command curl -I https://www.ornek.com/eski-sayfa should show 301 and a Location: line.
  2. Count the chain. If the target address redirects as well, change the rule to point straight to the final address. With curl -IL you can see the entire chain.
  3. Crawl a sample list. Test by hand first the pages that get the most traffic and the most links, then monitor the indexing of the new addresses in Search Console.

Image suggestion: a terminal screenshot showing the curl -I output, with the 301 and Location lines highlighted.

If you're having permission or configuration problems on the hosting side, take a look at our hosting and server services for server management.

When a page's address changes, the old URLs cited in AI answers and in classic search are not updated immediately either. Clean, single-hop redirects make it easier for both users and crawlers to reach the right page. For our article that looks at brand visibility from this angle, see the guide What is GEO? Visibility in AI search.

Quick checklist

  • The old-to-new URL mapping table is ready.
  • Redirects are set up server-side, with 301 (or 308).
  • There are no chains; every old address goes straight to the final address.
  • Pages with no equivalent return 404/410; they were not lumped into the homepage.
  • The new sitemap has been submitted to Search Console, and the old and new sites are verified.
  • Internal links have been updated to the new address.
  • Redirects will stay in place for at least 1 year.

Frequently asked questions

How long should a 301 redirect stay in place?

In its site move guide, Google recommends keeping redirects in place for as long as possible, generally at least 1 year. From a user's perspective, you can also consider keeping them indefinitely. Even so, the best approach is to update your own internal links and high-traffic external links to the new address.

What is the difference between a 301 and a 302 redirect?

A 301 signals that the page has moved permanently, and Google shows the new target address in search results. A 302 is temporary, and the source page keeps appearing in search results. If the move is not going to be reversed, use a 301 (or 308).

Does a 301 redirect hurt SEO?

A correctly set up 301 is the recommended way to tell Google a page's new address. Harm usually comes from incorrect setup: chained redirects, old pages lumped into an irrelevant target or the homepage, and redirects removed too early. Temporary fluctuations in rankings during a move are normal.

What should I do if the old page has no equivalent?

Don't redirect pages with no equivalent to the homepage. Google notes that this can confuse users and may be treated as a soft 404. If the content has been removed permanently, return a 404 or 410 response code; if several pages have been merged into one, you can redirect all of them to the merged page.

How do I add a 301 redirect to the .htaccess file?

On an Apache server, the simplest way is to add the line Redirect permanent /eski-sayfa https://www.ornek.com/yeni-sayfa to the .htaccess file. For pattern-based bulk redirects, use RewriteRule from mod_rewrite with the [R=301,L] flag. Back up the file before editing it and verify the result with curl -I.

Sources

İlgili Yazılar

Paylaş: LinkedIn X WhatsApp
Bu sayfayı yapay zekâ ile özetle:ChatGPTPerplexityClaudeGoogle AI ModeGrok
#301 yönlendirme #htaccess #site taşıma #teknik seo #yönlendirme
Gizlilik & Çerez Tercihleri

Bu web sitesi, size daha iyi bir deneyim sunmak ve ziyaret istatistiklerini analiz etmek için çerezler kullanmaktadır.

Zorunlu Çerezler
Bu çerezler web sitesinin düzgün çalışması için gereklidir ve kapatılamaz.
Her Zaman Açık
Analitik Çerezler
Sitemizi nasıl kullandığınızı anlamamıza yardımcı olan anonim ziyaret istatistikleri.
Pazarlama Çerezleri
İlgi alanlarınıza göre kişiselleştirilmiş içerik ve reklamlar sunar.