Redirect Setup in SEO | The Difference Between 301/302 and Writing Examples Explained

July 15, 2026

Author: Shusaku Yosa
SEOでのリダイレクト設定|301/302の違いと記述例を解説

Redirects always come up in situations like site renewals, URL changes, and switching to SSL. The most representative types are the 301 redirect and the 302 redirect, but confusing the two can cause an unintended URL to keep appearing in search results, or the consolidation of evaluation to not work well. This article explains, from the basics of redirects in SEO, the difference between 301 and 302 and how to use each, concrete examples of how to write them in .htaccess, and points to note when setting them up.

What is a redirect

A redirect is a mechanism that automatically forwards a user or search engine to a different URL when they access a certain URL. It is used in various situations, such as site relocation, URL structure changes, unifying the presence of www or http/https (URL canonicalization), and organizing old pages.

Redirects have several types depending on the HTTP status code, and the ones especially important for SEO are "301 (permanent forwarding)" and "302 (temporary forwarding)." It is important to correctly understand the difference in intent between these two and choose the one that fits your purpose.

The difference between a 301 redirect and a 302 redirect

301 and 302 are the same in that both perform automatic forwarding, but the "intent" they convey to search engines differs. The biggest difference is whether the forwarding is permanent or temporary.

301 redirect (permanent forwarding)

A 301 redirect is a status code indicating that "this page has permanently moved to a different location." When a search engine receives this instruction, it registers the new URL — not the old URL — as the canonical page in its index, and carries over the old page's evaluation to the new page. It is used in situations where you will keep using the new URL going forward, such as domain relocation, URL structure changes, and URL canonicalization.

302 redirect (temporary forwarding)

A 302 redirect is a status code indicating that a page has "temporarily moved to a different URL." Because the search engine tries to keep regarding the original URL as canonical, the old URL remains in the index. It is used in situations where you plan to return to the original URL later, such as temporary site maintenance, directing users to a campaign or promotion page, and A/B testing.

Choose based on "which URL you want shown," not "whether evaluation carries over"

It used to be explained that "301 loses part of the PageRank" or "302 does not carry over evaluation," but this understanding does not match the current mechanism. In 2016, Google stated that "30x redirects do not lose PageRank," and afterward it was also made explicit in Search Console help that 301 and 302 redirects do not lead to PageRank loss.

In other words, in Google today, there is no major difference in how SEO evaluation itself is passed on whether you choose 301 or 302. The decision axis is not "whether evaluation can be passed," but "which URL you want shown in search results." Thinking of it as 301 if you want the new URL shown in search results, and 302 if you want to keep the original URL, makes it less likely you will mistake which to use.

How to use 301 and 302

Use them according to intent, as follows. When in doubt, choosing 301 for a permanent forwarding is the basic rule.

  • When to use 301: domain relocation, URL changes in a site renewal, SSL conversion from http to https, canonicalization of www presence/absence or index.html presence/absence, consolidation of multiple pages
  • When to use 302: temporary site maintenance, directing users to a time-limited campaign or promotion page, A/B testing, temporary direction from an out-of-stock product page to a similar product

If you use 301 for A/B testing, the test page may be indexed as the canonical URL, risking a drop in traffic. Always use 302 for temporary forwarding. Conversely, for a deleted page, it is appropriate to return 404 (or 410) rather than 302.

How to set up redirects

There are multiple ways to set up redirects, depending on the server environment and CMS. The three representative ones are as follows.

  • Edit the .htaccess file (most common on Apache servers)
  • Use a WordPress plugin (such as Redirection; you can set it up just by entering from the admin screen, recommended if you are uneasy about editing code)
  • Do it from the rental server's control panel or server settings

Note that forwarding via meta refresh or JavaScript is technically possible, but because search engines may not stably interpret it as a "redirect," it is not recommended from an SEO perspective. As much as possible, choose a server-side redirect that returns 301/302 in the HTTP header.

Examples of how to write it in .htaccess

For an Apache server, writing it in the .htaccess file in the site's root directory is the most common. Here we introduce examples of writing for representative patterns.

301-redirect a specific page

This is an example of writing for permanently forwarding from an old page (/old-page/) to a new page.

RewriteEngine on RewriteRule ^old-page/$ https://example.com/new-page/ [R=301,L]

Replacing the "R=301" at the end with "R=302" makes the same code a temporary forwarding (302).

301-redirect the whole site to a different domain

This is an example of writing for forwarding all pages of an old domain to the same path on a new domain, such as in a domain relocation.

RewriteEngine on RewriteRule ^(.*)$ https://new-example.com/$1 [R=301,L]

SSL-conversion redirect from http to https

This is an example of writing for permanently forwarding all non-SSL (http) access to SSL (https).

RewriteEngine on RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Note that depending on the rental server, SSL-conversion redirect may be completed just by turning ON "forward to https" in the admin screen, in which case editing .htaccess is unnecessary.

Points to note when setting up redirects

Redirects are convenient, but if set up incorrectly, they can harm SEO and user experience. Pay attention to the following points.

  • Always back up before editing: a writing mistake in .htaccess can cause a server error or an infinite redirect loop
  • Avoid redirect chains: stacking forwarding over many steps (old → intermediate → new) harms display speed and how evaluation is passed, so complete it in one step as much as possible
  • Beware of leaving 302 in place long-term: keeping a supposedly temporary 302 set for a long time can lead Google to judge it as permanent and treat it as 301. Conversely, continuing to use 302 for a permanent relocation means the new URL is slow to be indexed
  • Return 404/410 for deleted pages: for pages that no longer exist, return an appropriate error code rather than a redirect
  • Also use it for canonicalization: if duplication arises from www presence/absence or index.html presence/absence, unifying to one side with 301 lets you consolidate the dispersed evaluation

Especially in domain relocations and large-scale renewals, a judgment error directly leads to the loss of the whole site's evaluation. Before setting up, organize the correspondence between forwarding sources and destinations, and after publishing, always confirm that the status codes are returned as intended.

Summary

Redirects in SEO are fundamentally about correctly using 301 (permanent) and 302 (temporary) according to intent. In Google today, there is no major difference in how evaluation is passed whichever you choose, and the decision axis has shifted to "which URL you want shown in search results." Use 301 for domain relocation, SSL conversion, and canonicalization, and 302 for temporary uses such as maintenance and A/B testing. For writing in .htaccess, thoroughly back up and avoid chains, and after setup, check the status codes to correctly carry over evaluation and the user path.

Related posts