4 minutes of reading

When to Use 301 Redirects? Key Types and Examples

When to Use 301 Redirects? Key Types and Examples - Image #1

301 redirects

Contents

You are now reading:

When to Use 301 Redirects? Key Types and Examples

Close

On the internet, everything has its place, defined by its URL. If for some reason it changes, it creates a number of difficulties – both for Google's crawlers, which are responsible for ranking the page, and for users searching for specific content. However, there is a solution – a 301 redirect is the virtual equivalent of changing your mailing address. Learn how it works and what types of 301 redirects can be used.

What is a 301 redirect?

A 301 (Moved Permanently) redirect is a mechanism that indicates that a page has been moved to a different address . It works automatically – meaning it doesn't display a "move" message, but instead redirects you to the correct page at the new URL . This saves search engine robots and internet users from having to wander around looking for specific content.

There are several types of redirects, but 301 is the most popular. It signifies a permanent relocation, meaning a permanent change to the website's address. This solution is very convenient from a user perspective and, at the same time, crucial for SEO. Thanks to the redirect, the website doesn't lose its established positioning or strength and can continue to build on it.

When is a 301 redirect used? Most common types

Constructing a 301 redirect may be necessary for various reasons. This is usually done in the .htaccess file—just use the appropriate code. There are several common types of redirects. Examples, along with the required code (replace "yourwebsite.com" with your own website address), can be found below.

(The rest of the article can be found below the form)

Fill out the form and schedule a call with an expert

We'll get to know your business and prepare a personalized quote for the optimal marketing mix. Completely free.

The controller of your personal data is Verseo, a limited liability company with its registered office in Poznań, at ul. Węglowa 1/3.

About Verseo

The Company's registered office is located in Poznań. The Company is entered in the Register of Entrepreneurs maintained by the District Court for Poznań – Nowe Miasto and Wilda in Poznań, 8th Commercial Division of the National Court Register, under KRS number: 0000910174, Tax Identification Number (NIP): 7773257986. You can contact us by mail at the address provided above or by email at: ochronadanych@verseo.pl

You have the right to:

  1. access to your data,
  2. rectification of your data,
  3. request deletion of data,
  4. processing restrictions,
  5. object to the processing of personal data,
  6. transfer of personal data,
  7. withdrawal of consent.

If you believe that we are processing your data contrary to legal requirements, you have the right to lodge a complaint with the supervisory authority – the President of the Personal Data Protection Office.

We process your data for the purpose of:

  1. handling your inquiry, pursuant to Article 6(1)(b) of the General Data Protection Regulation (GDPR);
  2. marketing purposes consisting in the promotion of our goods and services and ourselves in connection with the consent you have granted, pursuant to Article 6(1)(a) of the GDPR;
  3. securing or pursuing possible claims in connection with our legitimate interest, pursuant to Article 6(1)(f) of the GDPR.

Providing your data is voluntary . However, without it, you will not be able to send us a message, and we will not be able to respond to you.

We may transfer your data to trusted recipients:

  1. providers of tools for: website traffic analysis, sending marketing information.
  2. entities responsible for hosting (storing) the website and personal data.

We will process your data for the period of:

  1. necessary to achieve the specific purpose for which they were collected, and after its expiry for the period necessary to secure or pursue any claims
  2. in the case of data processing based on consent until its withdrawal. Withdrawal of consent does not affect the lawfulness of processing prior to withdrawal.

We do not process personal data in a way that would involve making solely automated decisions about you. More information regarding the processing of personal data can be found in our Privacy Policy.

  • 301 redirects from "www" to "no www" addresses

Website addresses can appear with or without the leading "www." If left unaddressed, this can create confusion, with traffic being distributed across two separate addresses, which is particularly detrimental to SEO.

Therefore, in such cases, a 301 redirect is most often used, allowing users to choose their preferred website address. This ensures that users will reach the target page regardless of whether they type "www.yourwebsite.pl" or "yourwebsite.pl" into the browser bar. This solution positively impacts optimization and enhances user experience.

Sample code:

RewriteCond %{HTTP_HOST} ^www.twojastrona.pl$

RewriteRule (.*)$ http://twojastrona.pl/ [R=301,L]

  • Domain change

Changing a domain name is a relatively common practice. In such cases, it's important to ensure redirection so that users can easily find the new address and that Google doesn't consider the transferred content as duplicate content , which is highly inadvisable for SEO purposes.

It's crucial to ensure that the 301 redirect applies not only to the home page but also to other tabs. The best solution is to use these to create direct paths to the new addresses for each subpage. It's worth the effort, if only to avoid discouraging users by hitting a wall, meaning they'll land on a page that no longer exists. This is also the only way to migrate your site without losing traffic.

It's best to implement a 301 redirect before migrating your data to the new address. This will ensure that crawlers correctly interpret your actions as a site move, not as creating a completely new site with duplicate content.

Sample code:

RewriteCond %{HTTP_HOST} ^yoursite.pl$

RewriteRule (.*)$ http://twojanowastrona.pl/ [R=301,L]

  • Changing HTTP to HTTPS

Using the SSL protocol involves changing the address from HTTP to HTTPS. This also requires redirection. 

Sample code:

RewriteCond %{HTTPS} !=on

RewriteRule (.*) https://%{HTTP_HOST}/ [R=301,L]

  • A slash ("/") at the end of the address

The same address, differing only by a slash at the end (e.g., "www.yourwebsite.pl" and "www.yourwebsite.pl/"), is treated as two separate pages by Google. Failure to redirect in this area is a very common mistake, causing the algorithm to interpret your content as duplicate content, making it virtually impossible to achieve a high ranking in search results.

Sample code:

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)/$ / [L,R=301]

  • Wildcard redirect

The wildcard feature helps you easily create new subdomains. However, in practice, it also means that entering any string of characters before your website's address will display its content, effectively creating a duplicate. Sometimes, Google crawlers index such pages, creating incredible chaos. Search results may then display several (or even dozens!) versions of the same address . For example, for example, www.yourwebsite.pl, it may also display www.www.yourwebsite.pl, www.yourwebsite.pl, or yourwebsite.yourwebsite.pl. This is very dangerous and may result in penalties from Google. The solution? A 301 redirect, which will redirect users and Google crawlers from each subdomain to the main page.

RewriteCond %{HTTP_HOST} ^(.+).yoursite.pl$

RewriteRule (.*)$ http://twojastrona.pl/ [R=301,L]

Other types of redirects

As a reminder, a 301 redirect is only used when a website's address is permanently changed . However, there are many other ways to redirect users to a different address and send a message to search engine robots. Other available redirect types include:

  • 302 (Found) – temporary, allowing content to be moved to another address and then returned to the original source;
  • 303 (See Other) – used with forms sending data via HTTP POST, enabling redirection to a specific address in response to that form;
  • 304 (Not Modified) – informs the browser that the data in its memory is current, has not changed, and therefore does not need to be downloaded from the source;
  • 305 (Use Proxy) – allows the use of a given resource only when using a specific proxy server, displays a message with the server address;
  • 307 (Temporary Redirect) – temporary redirect, does not allow changing the request method from POST to GET.

What to remember when using 301 and other redirects?

It's worth remembering that redirects are not only beneficial for users but also facilitate the work of Google robots and help ensure proper indexing of the site. Therefore, they have a positive impact on both UX and SEO. When used correctly, they can painlessly move pages to new addresses and allow for many other activities without affecting the site's ranking.

However, caution should be exercised when using different types of redirects. Using too many commands can create a loop, resulting in a 310 error (Too many redirects), which prevents you from reaching a specific page.

Summary

The above article covers the following topics:

  • What is "Moved Permanently"? 301 Status Explained
  • Status codes and redirects: 301, 302 and their impact on indexing