Skip to main content

How to 301 Redirect: A Technical and SEO Guide

Protect your SEO rankings during URL changes with 301 redirects here!

3D isometrik dengan jalur oranye yang mengalir di antara panel antarmuka, menggambarkan cara memasang 301

As a website owner, you might’ve made changes over time. You might restructure your URL hierarchy, migrate to a new domain, change from HTTP to HTTPS, or refine duplicate contents. Doing these changes can decrease your organic search performance, if you do it without a redirection strategy. 

A 301 redirect solves issues regarding redirection by forwarding users and crawlers from outdated URL to a live location. According to official Google Search Central, redirects provide the strongest signal to search engine algorithms that the target of the redirect should become canonical.  You can protect your website’s link equity, maintain user experience, and preserve indexing by understanding how to 301 redirect every time your website evolves. 

What is 301 Redirect?

Illustration of a 301 redirect from an old URL to a new URL

According to MDN Web Docs by Mozilla, 301 redirect or the HTTP 301 Moved Permanently is a status code showing a redirection response that the specific requested page has been moved permanently to the URL in the Location header. The new destination URL is in the Location header. 

HTTP Response Example:

HTTP/1.1 301 Moved Permanently
Location: /new-page/
Content-Type: text/html; charset = UTF-8

When receiving this status, the browser will automatically request the new destination in the Location header. This will forward the user to the new page. The ranking of the URL will be passed to the new redirected source, because search engines automatically attribute links from the original URL to the new one. 

Read Also: Types of SEO & The Right Strategy for Your Website

How to 301 Redirect

Illustration of a 301 redirect linking an old page to a new page

How to 301 redirect depends on your server architecture, access permissions, and CMS capabilities. Let’s learn how to implement 301 redirect through several methods as elaborated below. 

Method 1: Apache Web Server (.htaccess)

When you want to forward a URL to a new path on the same or different domain, add the following line to your .htaccess file:

Redirect 301 / old-page / / new-page/

If you want to make an entire domain migration, URL structural changes, or pattern matching, use Apache’s mod_rewrite module. You have to make sure that RewriteEngine On is active:

RewriteEngine On# Redirect a specific URL path
RewriteRule ^old-category/(.*)$ /new-category/$1 [R=301,L]

# Redirect HTTP to HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

Method 2: Nginx Web Server (nginx.conf)

Nginx processes configuration rules in its server block file. It’s typically located at /etc/nginx/sites-available/ or /etc/nginx/nginx.conf. For a single URL redirect, add this rewrite inside your server block:

server {

    listen 80;

    server_name domain.com;

    # Single page redirect

    rewrite ^/old-page$ /new-page permanent;

}

When you want to make an entire domain or directory migration, add this to your server block:

server {

    listen 80;

    server_name domain.com;

    # Redirect entire directory

    rewrite ^/old-blog/(.*)$ /new-blog/$1 permanent;

}

Method 3: Content Management Systems (Wordpress and E-Commerce)

If you don’t have access to server configuration files, you can also do it through CMS. For example, here’s how to redirect 301 in WordPress and Shopify:

WordPress via Plugins

You can manage redirects using plugins in WordPress like Redirection or Yoast SEO Premium. Here’s the step-by-step guide on how to 301 redirect in WordPress:

  1. Install and activate your preferred redirect plugin.
  2. Find the plugin settings menu. 
  3. Enter the relative path of the original URL in the ‘Source URL’ field.
  4. Enter the destination path in the ‘Target URL’ field.
  5. Set the HTTP match code to 301 - Moved Permanently.
  6. Save the rule when you’re done. 

Shopify Dashboard

E-Commerce platforms like Shopify also include redirection settings inside the admin interface. Here’s how:

  1. Visit Shopify and Log in to your Shopify Admin panel.
  2. Visit ‘Online Store’, and go to ‘Navigation.’
  3. At the top right, click ‘URL Redirects.’
  4. Click ‘Create URL Redirect.’
  5. Enter the old path in ‘Redirect from’ and the target destination in ‘Redirect to.’
  6. Once you’re done, click ‘Save redirect.’

Method 4: Cloudflare Edge Redirects

On Cloudflare, you can set up 301 redirects by using the Redirect Rules in your dashboard. Here’s how:

  1. Log in to the CloudFlare Dashboard and select your domain. 
  2. Click ‘Rules’ and then ‘Single Redirects.’
  3. Click ‘Create rule.’
  4. Set the target action to Dynamic or Static Redirect.
  5. Select ‘301’ as the status code.
  6. Save and deploy the rule.

Difference between 301 Redirect vs. 302 Redirect 

You may also encounter a 302 redirect. Though both 301 and 302 are redirects, 302 acts as a temporary redirection, and search engines handle this differently. Make sure that you don’t accidentally use 302 redirect when you want to do a permanent redirect. It will cause indexation errors and delay ranking consolidation. Learn the difference between these two to avoid any redirection mistakes. 

Status Code

Redirect Type

Search Engine Handling

Use Case

301

Permanent

Passes ranking signals to target and canonicalizes target.

Domain migration, site restructuring, permanent URL changes. 

302

Temporary

Doesn’t fully transfer link equity immediately and retains indexation on the original URL.

Localized maintenance, A/B testings, and temporary promotion. 

SEO Best Practices for 301 Redirect

Illustration of SEO best practices for 301 redirects

Deploying the code is only one part of the task. To obtain optimal results in terms of search engine re-indexing and user experience, the technical implementation should be done correctly. Here’s the step-by-step to help you get started with migrating your domain with SEO best practices strategy.

1. One-to-One Redirects 

Redirect each old page to its closest matching equivalent on the new site structure. Don’t  redirect deleted or irrelevant URLs by pointing them to your homepage. According to Google Search Central, search engines will recognize such redirects a Soft 404 errors. This will prevent link equity transfer and create misleading signals for crawlers.

2. Eliminate Chained and Loop Redirects

A redirect chain is when URL A redirects to URL B which then redirects to URL C. Every additional page in the redirect chain only makes the redirects slower. 

A redirect loop is when URL A redirects to URL B, and then URL B redirects back to URL A. Search engines have a limited budget for crawling pages, and browsers will show an error (ERR_TOO_MANY_REDIRECTS) if they get caught in a loop. 

3. Consistent Trailing Slashes and Protocols

The next optimization is maintaining consistent trailing slashes and protocols. Here’s what you need to do:

  • Use your preferred format and redirect all variations to it. 
  • HTTP version $\rightarrow$ HTTPS version.
  • Non-WWW version $\rightarrow$ WWW version (or vice versa).
  • Trailing slash $\rightarrow$ Non-trailing slash (or vice versa).

It’s very important to update your internal links and sitemaps regularly. Not all links on a website are external ones, since there are also internal links that lead to other pages on the same domain. 

Google Search Central recommends updating them to the new URLs directly rather than relying on redirects. By doing so, you will reduce the number of redirects that crawlers will have to follow in order to reach the desired page. 

How to Validate 301 Redirect

Illustration of how to validate a 301 redirect

Make sure that you always verify your redirection setup in a live environment to confirm correct status response code. Here’s how you can validate and monitor your 301 redirect. 

Terminal Check via curl

 Execute a HEAD request in your terminal to view raw response headers without downloading page body content:

curl -I https://developers.google.com/search/docs/crawling-indexing/301-redirectsCheck that the first line returns HTTP/1.1 301 Moved Permanently and verify that the Location header matches your desired target path.

Google Search Console 

You can also use the ‘URL Inspection tool’ in Google Search Console to check how Googlebot sees your old URL. You can also monitor index coverage reports and sitemaps to verify that Google had discovered the redirects and successfully indexed the new canonical pages. 

Read Also: What is Schema Markup and How to Implement It to Boost SEO

Take Control of Your URL Redirection Strategy

Implementing 301 redirect correctly will help you maintain your rankings, keep the link equity, and provide a good user experience. It doesn’t matter if you’re restructuring URls, developing a brand new website, or migrating an entire domain, proper HTTP status code management will help you retain your visibility in the search result.

Developing a fast and SEO-friendly website and migration require technical expertise and precision. Crawl Compass can help you build a website from scratch and increase your SEO performance by implementing technical SEO recommendations. 

We specialize in web development and technical SEO services. Let us handle any kind of migration or redirection projects for you! 

Contact Crawl Compass and get your next web project developed and managed by SEO professionals to scale your business growth!

Frequently asked questions

What is a 301 redirect?
A 301 redirect is a permanent HTTP status code that forwards the user and search engine from an old URL to a new one.
Should I use 301 or 308?
Use 308 redirect only when you must preserve non-GET request methods.
Is a 302 redirect permanent?
302 is a temporary redirect, the permanent one is 301 redirect.
What happens if I use a 302 redirect instead of a 301?
Since 302 redirect signals a temporary change, search engines continue to index the old URL and may withhold link equity from the new destination.
How do I fix a redirect chain?
You can identify redirect chains using site audit tools like Screaming Frog or online headline checkers. Reconfigure the initial source URL rule to point directly to the new one.

Related reading

Get the Search Journal in your inbox.

New articles and research, sent when we publish.