SEO Image Blog

SEO Image Blog

301 Redirects & Canonical URL Tutorial

Test your redirects with the SEO Image Redirect Checker

A 301 redirect tells browsers and search engines that a URL has permanently moved to a new location. When implemented correctly, it sends visitors to the appropriate replacement page and helps search engines transfer signals associated with the old URL to the new one.

Redirects are commonly needed when changing a page URL, consolidating duplicate content, moving from HTTP to HTTPS, changing domains, reorganizing a website, or removing an outdated page that has a relevant replacement.

This guide explains when to use a 301 redirect, how it differs from other redirect types and canonical tags, and how to implement redirects on WordPress, Apache, NGINX, Microsoft IIS, and PHP.

What Is a 301 Redirect?

A 301 redirect is an HTTP response that means the requested resource has moved permanently. When someone requests the old URL, the server returns a 301 status code and a new destination in the Location header.

For example:

Old URL:
https://www.example.com/old-page/

301 redirects to:
https://www.example.com/new-page/

The browser then requests the destination URL. Search engines can also replace the old URL with the new URL in their indexes after processing the redirect.

301 vs. 302, 307, and 308 redirects

Status Meaning Typical use
301 Moved Permanently A page or site has permanently moved
302 Found / Temporary Redirect A temporary change, test, or short-term alternate destination
307 Temporary Redirect A temporary redirect that preserves the original request method
308 Permanent Redirect A permanent redirect that preserves the original request method

A 302 redirect is not inherently bad for SEO. It is appropriate when the move is genuinely temporary, such as an A/B test or a short-term promotional page. The problem occurs when a temporary redirect is used for a permanent URL change.

For standard web pages requested with GET, a 301 is still the most familiar permanent redirect. A 308 is also permanent and is particularly useful when the original HTTP request method and body must remain unchanged.

When Should You Use a 301 Redirect?

Use a 301 redirect when the old URL should no longer be treated as the primary location and there is a relevant permanent replacement.

Common situations include changing a page slug, consolidating two similar articles, moving a site to HTTPS, selecting either the www or non-www hostname, changing domains, or replacing an outdated product or service page with a close equivalent.

Redirecting a deleted page

Do not redirect every removed URL to the home page. The destination should satisfy the same or a closely related user intent.

If an old article has been merged into a more complete guide, redirect it to that guide. If a discontinued product has a direct replacement, redirect it to the replacement. If there is no relevant alternative, allowing the old URL to return a 404 or 410 response may be more accurate than forcing an unrelated redirect.

301 Redirects vs. Canonical Tags

A 301 redirect and a canonical tag are not interchangeable.

Use a 301 redirect when:

The old URL should no longer be available to users or search engines. Everyone requesting it should be sent to the new URL.

Use a canonical tag when:

Multiple accessible URLs contain the same or substantially similar content, but you still need those URLs to remain available. The canonical tag indicates which URL you prefer search engines to index.

For example, a product page may be accessible through tracking parameters or filtered URLs while identifying the clean product URL as canonical.

<link rel="canonical" href="https://www.example.com/preferred-page/">

A canonical tag is a signal, not a forced redirect. Visitors can still access the noncanonical URL.

Do Not Use Canonical Tags as a Substitute for Site Migrations

When a page or domain permanently moves, use server-side redirects. Do not leave the old pages active and rely only on cross-domain canonical tags when a real move has occurred.

How to Create 301 Redirects in WordPress

WordPress redirects can be handled through the server configuration, a redirect plugin, an SEO plugin with redirect functionality, or custom PHP. For most site owners, a reliable redirect manager is the simplest option.

Using a WordPress redirect plugin

A redirect plugin typically asks for:

Source URL: the old path being requested

/old-page/

Target URL: the new destination

https://www.example.com/new-page/

Select a 301 or permanent redirect and save the rule.

After creating it, test the old URL to confirm that it returns one 301 response followed by a 200 response from the destination.

WordPress redirect best practices

Update internal links to point directly to the new URL rather than relying on the redirect. Remove the old URL from menus, XML sitemaps, canonical tags, structured data, and content links.

A redirect plugin can be convenient, but server-level redirects are usually processed before WordPress loads and may be preferable for large migrations or high-traffic websites.

301 Redirects for Apache and .htaccess

Apache websites commonly use either mod_alias or mod_rewrite. For a straightforward one-to-one redirect, the simpler Redirect directive is usually preferable.

The .htaccess file is commonly located in the website root on shared Apache hosting. Make a backup before editing it, because a syntax error can cause the site to return a server error.

Redirect one page

Redirect 301 /old-page/ https://www.example.com/new-page/

You can also use:

Redirect permanent /old-page/ https://www.example.com/new-page/

Apache treats Redirect permanent as a 301 redirect.

Redirect one old file

Redirect 301 /old-page.html https://www.example.com/new-page/

Where to place redirects in a WordPress .htaccess file

Place custom redirects before the standard WordPress rewrite section:

# Custom redirects
Redirect 301 /old-page/ https://www.example.com/new-page/

# BEGIN WordPress
...
# END WordPress

Redirect a directory while preserving the remaining path

RedirectMatch 301 ^/old-folder/(.*)$ https://www.example.com/new-folder/$1

This redirects:

/old-folder/page-one/
to
/new-folder/page-one/

Redirect non-www to www

RewriteEngine On

RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301,L]

Redirect www to non-www

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L]

Force HTTPS

RewriteEngine On

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

If the website is behind a reverse proxy, load balancer, CDN, or managed hosting platform, the server may receive HTTP even when the visitor used HTTPS. In that environment, ask the host how HTTPS is reported before adding a rule. An incorrect rule involving X-Forwarded-Proto can create an infinite redirect loop.

Force HTTPS and a preferred hostname in one redirect

Combining protocol and hostname normalization helps prevent a two-step chain such as HTTP non-www to HTTPS non-www to HTTPS www.

RewriteEngine On

RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301,L]

Redirect an old domain to a new domain

Place this on the old domain:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(?:www\.)?old-domain\.com$ [NC]
RewriteRule ^ https://www.new-domain.com%{REQUEST_URI} [R=301,L]

This preserves the requested path:

https://old-domain.com/services/
to
https://www.new-domain.com/services/

Only preserve every path automatically when the old and new sites have matching URL structures. Otherwise, create a page-by-page redirect map.

301 Redirects for NGINX

NGINX does not use .htaccess. Redirects are added to the server configuration, typically within a server block.

The return directive is generally the cleanest option for simple redirects.

Redirect one page

location = /old-page/ {
    return 301 https://www.example.com/new-page/;
}

Redirect HTTP to HTTPS

server {
    listen 80;
    server_name example.com www.example.com;

    return 301 https://www.example.com$request_uri;
}

Redirect non-www to www

server {
    listen 80;
    listen 443 ssl;
    server_name example.com;

    return 301 https://www.example.com$request_uri;
}

Redirect an old domain

server {
    listen 80;
    listen 443 ssl;
    server_name old-domain.com www.old-domain.com;

    return 301 https://www.new-domain.com$request_uri;
}

After editing the configuration, test it before reloading NGINX:

nginx -t

Then reload the server using the command appropriate for your environment.

301 Redirects for Microsoft IIS

Microsoft IIS can handle permanent redirects through the HTTP Redirect feature or the IIS URL Rewrite module.

Using the IIS URL Rewrite interface

Open IIS Manager, select the website, open URL Rewrite, and create a new inbound rule. Choose a redirect action, enter the destination URL, and set the redirect type to Permanent (301).

Example web.config rule for HTTP to HTTPS

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Redirect to HTTPS" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTPS}" pattern="off" ignoreCase="true" />
          </conditions>
          <action
            type="Redirect"
            url="https://{HTTP_HOST}/{R:1}"
            redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

Example web.config rule for one URL

<rule name="Redirect old page" stopProcessing="true">
  <match url="^old-page/?$" />
  <action
    type="Redirect"
    url="https://www.example.com/new-page/"
    redirectType="Permanent" />
</rule>

Rules in web.config normally match the URL path without the opening slash.

How to Create a 301 Redirect in PHP

A PHP redirect must be sent before any HTML, spaces, or other output is returned to the browser.

PHP 301 redirect

<?php
header('Location: https://www.example.com/new-page/', true, 301);
exit;
?>

The exit statement prevents the rest of the old page from executing after the redirect header is sent.

PHP 302 temporary redirect

<?php
header('Location: https://www.example.com/temporary-page/', true, 302);
exit;
?>

Use the temporary version only when you intend to return visitors to the original URL later.

How to Redirect a Website to a New Domain

A domain migration requires more than adding one general redirect. Each important old URL should point to the closest matching URL on the new domain.

For example:

old-domain.com/services/seo/
to
new-domain.com/seo-services/

Do not redirect every old URL to the new home page unless the home page is genuinely the closest replacement.

Recommended migration process

  1. Create a complete list of indexed, linked, and traffic-generating URLs on the old site.
  2. Map each old URL to the most relevant new URL.
  3. Implement direct server-side 301 redirects.
  4. Update internal links, canonical tags, hreflang, structured data, and XML sitemaps.
  5. Keep both the old and new domain properties verified in Google Search Console.
  6. Submit the new XML sitemap.
  7. Use Google’s Change of Address tool when moving the entire domain and when the tool is applicable.
  8. Monitor crawl errors, indexing, traffic, rankings, and redirect behavior.

Keep the old domain and redirects active for as long as practical. Existing links, bookmarks, citations, and old documents may continue sending traffic for years.

SEO Best Practices for 301 Redirects

Use the closest relevant destination

Redirect the old page to a page with equivalent or closely related content. Relevance is more important than simply sending every URL somewhere.

Avoid redirect chains

A redirect chain occurs when one URL redirects to another URL that redirects again:

URL A → URL B → URL C

Update the first redirect so it points directly to the final destination:

URL A → URL C

Avoid redirect loops

A loop occurs when redirects send a request back to a URL already visited:

URL A → URL B → URL A

Redirect loops prevent the destination from loading and often produce a browser error.

Update internal links

Redirects are useful for old external links and bookmarks, but your own website should link directly to the destination URL.

Do not redirect robots.txt-blocked URLs and expect quick processing

Search engines need to crawl the old URL to see the redirect. Blocking the old URL in robots.txt can interfere with that process.

Keep canonical tags consistent

The destination page should normally contain a self-referencing canonical tag. Do not redirect to one URL while declaring a different URL canonical unless there is a deliberate technical reason.

Check query strings

Some redirect methods preserve query strings automatically, while others replace or remove them. Test URLs containing tracking parameters, filters, and campaign codes when they matter.

How to Test a 301 Redirect

Use the SEO Image Redirect Checker to verify the complete response path.

An ideal result for a permanent page move is:

Old URL: 301 Moved Permanently
New URL: 200 OK

Check that:

  • The first response is 301, not 302
  • The destination is the intended URL
  • There is no unnecessary redirect chain
  • The final page returns 200 OK
  • HTTP, HTTPS, www, and non-www variations behave consistently
  • The redirect preserves the correct path and query string when required
  • The destination does not redirect back to the source

Testing with curl

To inspect the first response:

curl -I https://www.example.com/old-page/

To follow the full redirect path:

curl -I -L https://www.example.com/old-page/

Common 301 Redirect Mistakes

The most common redirect problems are not caused by the 301 status itself. They result from poor mapping or conflicting technical rules.

Watch for redirects to irrelevant pages, chains created by old rules, HTTP and hostname redirects running separately, both a plugin and .htaccess controlling the same URL, incorrect regular expressions, redirecting all 404 pages to the home page, and forgetting to update internal links.

Browser caching can also make a corrected 301 appear unchanged during testing. Use a fresh private window, a header checker, or command-line testing rather than relying only on a previously cached browser request.

301 Redirect Checklist

Before considering a redirect complete, confirm that the old URL returns one permanent redirect, the final destination returns 200 OK, the content is closely related, internal links point directly to the new URL, and the old URL has been removed from the XML sitemap.

Check Your Redirects

Confirm that your redirects return the correct status code and do not create chains or loops.

Use the SEO Image Redirect Checker

    SEO & Reputation Management Services in NYC & Long Island


    Don’t let poor search results or a damaged reputation hold you back.
    SEO Image can help fix it.

    Call 888-736-2667 or send a message below.

    X