Ошибка 301 api

From Wikipedia, the free encyclopedia

HTTP 301 is the HTTP response status code for 301 Moved Permanently. It is used for permanent redirecting, meaning that links or records returning this response should be updated. The new URL should be provided in the Location field, included with the response. The 301 redirect is considered a best practice for upgrading users from HTTP to HTTPS.

RFC 2616[1] states that:

  • If a client has link-editing capabilities, it should update all references to the Request URL.
  • The response is cacheable unless indicated otherwise.
  • Unless the request method was HEAD, the entity should contain a small hypertext note with a hyperlink to the new URL(s).
  • If the 301 status code is received in response to a request of any type other than GET or HEAD, the client must ask the user before redirecting.

Examples[edit]

Client request:

GET /index.php HTTP/1.1
Host: www.example.org

Server response:

HTTP/1.1 301 Moved Permanently
Location: https://www.example.org/index.asp

Using an .htaccess file[edit]

To fix problems with non-existing files or directories using a distributed .htaccess file:

Redirect 301 /calendar.html /calendar/
Redirect 301 /not_found.html /

Here is an example using a .htaccess file to redirect a non-secure URL to a secure address without the leading «www»:

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

RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R,L]

Static HTML[edit]

A custom directory redirect, using an index.html file:

<meta http-equiv="refresh" content="0; url=/" />
<p><a href="/">Home</a></p>

Using programming languages[edit]

Here is an example using Perl CGI.pm:

print redirect("https://example.com/newpage.html");

Here is an example using a PHP redirect:

<?php
header("Location: https://example.com/newpage.html", true, 301);
exit;

Here is one way to redirect using Express.js:

app.all("/old/url", (req, res) => {
    res.redirect(301, "/new/url");
});

Caching server[edit]

Equivalently simple for an nginx configuration:

location /old/url {
    return 301 '/new/url';
}

Search engines[edit]

Both Bing and Google recommend using a 301 redirect to change the URL of a page as it is shown in search engine results, providing that URL will permanently change and is not due to be changed again any time soon.[2][3]

Technical Details[edit]

The HTTP 301 status code has several technical nuances that developers should be aware of when implementing and managing redirections:

Browser Handling[edit]

  • Caching Behavior: Many web browsers cache 301 redirects. This means that once a user’s browser encounters a 301 redirect, subsequent requests to the original URL will be automatically directed to the new URL without contacting the server.
  • Updating Bookmarks: Browsers may update bookmarks to reflect the new URL after encountering a 301 redirect.

Comparison with Other Status Codes[edit]

  • 302 Found: Unlike a 301, a 302 status code indicates a temporary redirect. Search engines might not pass the SEO value to the new URL.[4]
  • 307 Temporary Redirect: Like 302, but guarantees that the method and the body will not be changed when the redirected request is made.
  • 303 See Other: Used when the result of a POST or another non-idempotent request method is a resource that should be retrieved using a GET.

[edit]

  • Mandatory Inclusion: The new URL should always be provided in the «Location» field when a 301 redirect is sent. Omitting the Location header will confuse browsers and may result in unexpected behavior.
  • Absolute URL Usage: While relative URLs might be accepted by some browsers, using absolute URLs in the Location header is the standard and ensures consistent behavior across all user agents.

Impact on SEO[edit]

  • Link Equity Transfer: Search engines typically transfer a majority of the link equity (or “link juice”) from the source URL to the target URL for 301 redirects.[5]
  • Indexing Delays: There might be a lag before search engines recognize the redirect and update their indexes accordingly.

Common Pitfalls[edit]

  • Multiple Redirects: Using multiple 301 redirects in succession (A to B, then B to C) can lead to increased page load times and may dilute SEO value.
  • Mixed Content Issues: When redirecting from HTTP to HTTPS, ensure that all resources (images, scripts, stylesheets) on the page are also loaded over HTTPS to prevent mixed content warnings.

See also[edit]

  • Hypertext Transfer Protocol
  • List of HTTP status codes
  • URL redirection

References[edit]

  1. ^ Fielding; et al. (June 1999). 10.3.2 301 Moved Permanently. IETF. p. 61. sec. 10.3.2. doi:10.17487/RFC2616. RFC 2616.
  2. ^ «Site Move Tool». Bing Webmaster Help & How-to.
  3. ^ «301 redirects». Google Webmaster Tools Help.
  4. ^ SEO and HTTP status codes: A comprehensive analysis
  5. ^ 301 Redirects Explained: How They Impact SEO

301 Error Code

Introduction

Learn about 301 redirects and the most common errors so you can avoid them in
the future. Fortunately, you’ve found your way here.

Think of it as if you’re creating a brand new webpage or an entire website
from scratch. Alternatively, you may be moving your website. Your domain name
may contain a typo. You’ve concluded that using the same URL is no longer
feasible. What are you doing?

A 301 permanently relocated status code is what you use. The purpose of these
codes is to redirect your customers to a different location. «The requested
document has been permanently relocated.» Users will try to access a page, but
will instead be redirected elsewhere.

You need to know the
301 status code, as well as how to find and fix 301 errors, here.

What Does 301 Permanently Moved Mean?

HTTP status codes
come in a wide variety of flavors. There are a variety of ways to tell the
user if a specific HTTP request has been successful. In total, there are five
levels:

  • Responses that provide data (such as 100 Continue and 101 Switching
    Protocols)
  • Successful outcomes
  • Reroutes traffic
  • Mistakes by the user (like
    404 Page Not Found)
  • as well as server issues

There is a redirection indicated by the 3xx HTTP status code. Instead of the
original URL, users and search engines will be redirected to a new one. There
are a variety of 3xx status codes, such as 302, 303, and 307, each with their
unique interpretation.

301 status codes should be used when you’re permanently changing one URL for
another. In other words, the old URL will be redirected to the new one for
people and bots alike.

Website.com/blog redirects to blog.website.com

It would sound something like this to a real person:

Visitor: For the time being, this page has been relocated, and we have
no plans to return it.

Browser: I see now. I’ll direct your existing customers to the new
URL.

There will be no need for the old URL, as it will no longer appear in the
search results. The old URL’s link equity will be transferred to the new
URL.

As a result, whenever you’re doing a site migration or removing an old page
and replacing it with a new one, you’ll want to perform a 301 Moved
Permanently redirect.

How do 301 and 302 redirections differ?

A 301 redirect is superior to a 302 redirect. Have trouble deciding which
one to use?

The fact that you’re feeling this way isn’t unique.

Even in 2019, website owners are unsure of which type of redirect is best for
search engine optimization (SEO).

A redirect can be useful for a variety of reasons. Below are the most
frequently used justifications:

  • You’ve launched a brand-new site. 
  • Creation of a new page for you.
  • There is a problem with your URL.

For example, you’re working on an issue with a page and want to redirect users
to another page.

The decision is heavily influenced by the redirect’s intended outcome. When it
comes to SEO, it’s important to know the difference between the two.

Search engines need to be informed that a website or page has been permanently
relocated by a 301 redirect. If you’re moving a website or creating a new one,
you should use an HTTP 301. Usage of 301 is appropriate if you’re joining two
websites together. However, 301 is also useful if you’re making modifications
to the URL that are not meant to be reversed.

Using a 302 redirect lets search engines know that a website or page has been
temporarily redirected elsewhere. If you’re redesigning or updating a website
or a page, you should use this redirect. You can also use the redirect to test
out a new page and get feedback from customers. Only use a 302 redirect if you
intend to bring the old website or page back online in the future.

A 301 redirect lasts how long?

It is typical for a 301 redirect to remain in place for a year or more. Check
to see if you’re new URL is still being sent to users after that.

Fixing 301 redirects is a question I frequently get

Error 301 is a common occurrence for website owners of all skill levels. To
keep your website in good working order, it’s important to know what’s wrong
and how to fix it. When dealing with these kinds of issues, regular website
maintenance is a must, and here are the most common and best ways to resolve
them.

Check to see if your HTTP version is redirecting to your HTTPS version.

Using HTTPS on your site can help protect the personal information of your
site’s visitors. For additional information, Google uses HTTPS as a ranking
factor. To put it another way, not encrypting your website traffic with HTTPS
can harm your search engine results. For the sake of everyone’s safety online,
Google hopes that this move will encourage all website owners to make the
switch from HTTP to HTTPS. It’s 2019 and HTTPS is a no-brainer.

However, if your users are not redirected to the secure HTTPS version, using
HTTPS is of no use. In other words, you’ll need to use an HTTP 301 to switch
between HTTP and HTTPS.

Check the URL bar of your homepage to see if the 301 redirect works between
your two versions. The following is what you’ll see:

https://www.technologycrowds.com/

Enter the URL
https://www.technologycrowds.com/  by removing the «s» from the beginning. A redirect to the secure HTTPS
version of your site should occur if all goes well.

Get rid of all of the 301 redirects on your website

To better crawl your site, Google consults your
sitemap
file. However, since your redirected pages don’t exist, Google has no reason
to crawl them.

301 error status codes can be removed by performing the following steps:

Yourdomain.com/sitemap.xml can be found at this location (keep in mind that
your sitemap URL might be different as there are exceptions).

Use a URL Extractor to download a list of all of your URLs in one place.

  • Use any free tool to paste the list.
  • Use a 301 status code to narrow the results.
  • Replace the 301 URLs in the sitemap file with the final URL. 
  • Delete the 301 URLs from the sitemap file.
  • Redirect chains are to be avoided at all costs.

When the original URL and the final URL are connected by more than one
redirect, this is known as a redirect chain. If you want to see an example of
this, look at Page 1. Nevertheless, Google cautions against the use of
redirect chains, citing the negative impact on user experience (UX) and the
resulting slowdown on site performance.

Link farms are bad for SEO, too. Only about 85% of link equity is passed
through 301 redirects, according to industry estimates. In other words, the
more redirects there are, the worse the situation.

Ensure that the final URL is redirected to. A few pointers:

Redirect chains can be found using a tool like this.

The redirect chain should be replaced with a single 301 redirect once you’ve
found them. In place of Page 1, Page 2, and then Page 3, the redirect goes to
Page 1 and then Page 3.

In addition, you can replace internal links to redirected pages with direct
links to the final URL.

Remove redirect loops

URLs that are linked together can create a redirect loop when one of them
redirects users back to another URL. There are many examples of this, such as
the following:

As soon as possible, you’ll want to address this problem.

Use a free tool to scan up to 100 URLs for errors indicating that the maximum
number of redirects has been exceeded.

You can fix redirect loops in two ways once you find them:

If you don’t want the URL to redirect, change the HTTPS response code to
200.

You should fix the final destination URL if the URL is supposed to reroute.

Your redirects need to be fixed.

If a link is broken, it takes you to a page that doesn’t exist! Page 1 (301)
> Page 2 (302), for example (404). Your website’s search engine rankings
and user experience could suffer as a result.

To check for broken redirects in batches of 100, use the tool we mentioned
above.

You can fix any errors you find by:

  • Reviving a long-dead page
  • Deleting the redirected URL’s in-links.

Redirects from 302 to 301 should be used instead.

If you want to move permanently, you should never use 302 redirects. Removing
or replacing an HTTP response status code 302 redirect that is in place
because of a long-term move is the best course of action.

301 redirect pages that receive traffic should be examined.

This code tells the browser that a page has permanently relocated to a new
URL. There should be no organic traffic to that page. Chances are that Google
will notice the HTTP 301 if you recently added it.

Use a tool like Moz, SemRush, or Ahrefs to look for redirected pages that are
still receiving organic traffic.

Remove the pages from your sitemap and re-submit them through Google Search
Console once you’ve located them.

The most important things to remember

A 301 redirect is a permanent way of sending a URL to a new location. Search
engines and website visitors alike will be alerted to the URL’s new location
if you do this.

You must have a strategy in place and use redirects wisely. Organic traffic
can be greatly increased by correctly implementing HTTP 301. Follow the advice
above if you’re concerned that your website has unresolved 301 Moved
Permanently errors.

HTTP Status 301 is one of the redirection related statuses, which indicates that the resource requested has been permanently moved to the URL given by the Location header. And all the future requests should use the new URI.

Redirection is the process of forwarding the request from one URL to a different URL. The specification for Status 301 requires the request method (and the request body) not to be altered when the redirection is performed.

It is recommended to use HTTP 301 only for GET or HEAD methods.

1. Why a URL needs to move permanently?

Generally, changing the URLs of resources is not advisable. Still, we can come across unavoidable situations where we must be making the changes to the URL of a resource.

A few such examples can be:

  • Moving the resource from HTTP to HTTPs protocol
  • Resource has been discountinued and alternate resource is available in new URL

2. Location Header

The server SHOULD generate a Location header field in the response containing the new location of the resource.

2.1. Client request

GET /index.php HTTP/1.1
Host: www.example.com

2.2. Server response

HTTP/1.1 301 Moved Permanently
Location: https://example.com/index.asp

3. Cachable

A 301 response is cacheable by default; i.e., unless otherwise indicated by the method definition or explicit cache controls.

Refer to these cache headers for more information.

4. Response Handling

  • If a client has link-editing capabilities, it should update all references to the requested URL with the new URL.
  • Search engines (Google and Bing) replace the old URL in the search results, and the old URL will eventually disappear. Link juice will pass from the old URL to the new URL.
  • The browsers will automatically detect the 301 response code after that it will read the new location URL and redirect the request to that new location.

Reference : RFC 7231

HTTP response status code 301 Moved Permanently is returned by the server to indicate that the resource has been given a new permanent location.

The HTTP response is cacheable by default. If the default behavior needs to be overridden then the HTTP response must include the appropriate HTTP caching headers.

Usage

When the 301 Moved Permanently status code is received, clients are expected to update their stored links to the new URI. The new URI is specified by the Location HTTP header and can be used by the client for automatic redirection.

This message might be sent by servers that have migrated to a new domain, or have reorganized their internal file structure, and do not plan on reverting to the former URI.

Note

301 Moved Permanently status code allows for the client to change the HTTP request. For example, if the original HTTP request is a HTTP POST request then the follow-up may be a HTTP GET request. This differs from the 308 Permanent Redirect status code, which requires that an identical request be sent in HTTP response.

Example

In the example, the client attempts to retrieve an HTML resource. The server responds to say that the resource has permanently moved to a new URI and includes it in the Location HTTP header. Client-side, a message is presented in the message body to suggest updating the relevant bookmarks, however this is seldom visible in modern browsers which straight away redirect to the new location.

Request

GET /news.html HTTP/1.1
Host: www.example.re

Response

HTTP/1.1 301 Moved Permanently
Location: http//www.example.re/feeds/news.html
Content-Type: text/html; charset=UTF-8
Content-Length: 150

<h1>The Newsfeed has moved</h1>
<body>
The newsfeed has moved permanently to <a href=/feeds/news.html>here</a>. Please update your bookmarks.
</body>

Code references

.NET

HttpStatusCode.MovedPermanently

Rust

http::StatusCode::MOVED_PERMANENTLY

Rails

:moved_permanently

Go

http.StatusMovedPermanently

Symfony

Response::HTTP_MOVED_PERMANENTLY

Python3.5+

http.HTTPStatus.MOVED_PERMANENTLY

Java

java.net.HttpURLConnection.HTTP_MOVED_PERM

Apache HttpComponents Core

org.apache.hc.core5.http.HttpStatus.SC_MOVED_PERMANENTLY

Angular

@angular/common/http/HttpStatusCode.MovedPermanently

Takeaway

The 301 Moved Permanently status code indicates that the resource has moved to a new location that is specified within the HTTP response. Clients are expected to update their internal data accordingly.

See also

  • 308 Permanent Redirect
  • RFC 7231

Last updated: August 2, 2023

Status Code 301: «Moved Permanently»

HTTP Status Code 301: «Moved Permanently»

Status code 301 is shown when a page has been moved. They are colloquially known as “301 redirects”.

They should be used any time you have permanently replaced a URL with another URL. Users and bots will be permanently moved to the new URL, which will replace the old URL in search engines results. Eventually, the old URL will disappear.

What is critical and probably most important about these redirects is that the link equity has passed from the old URL to the new URL. That means that, if you’ve acquired a bunch of links on an old URL and you 301 redirect that old URL to the new one, you’re going to get all that link equity—and the new URL has the potential to replace the old one in search results.

Sites with bad technical SEO will often have 302 redirects, also known as temporary redirects. These tell search engines that the page is only being moved temporarily, and they should come back and check on it later.

301 redirects play a crucial role in SEO as they maintain search engine rankings during URL changes.

In general, from an SEO perspective, you want to use 301 redirects, and avoid 302 redirects.

The HTTP Protocol

Let’s talk about how the HTTP protocol works.

At its very foundation, the Internet is made up of two core things: clients and servers.

Any time you click on your browser, you are accessing the Internet through a web client. It may be Chrome, Firefox, Safari or Internet Explorer.

When you visit a website, you are making a request to a web server.

Facebook.com, ClickMinded.com, MarthaStewart.com/1525880/marthas-chocolate-chip-cookies, all of these sites have their own home address. It’s called an IP address.

Your home address might be 123 Main Street, New York, NY 10001, and Facebook’s address happens to be 66.220.144.0.

Whenever you visit a page on the web, you are requesting a whole bunch of documents from that website’s server. Maybe those documents are HTML, CSS, images, a PDF—whatever it is, the basic relationship stays the same: you (the client), make a request, and the website (the web server) provides a server response to that request.

The language you are using to make these requests is called the HTTP protocol. These protocols are really just standards that everyone on the web has agreed to. Just like English, Spanish and Chinese are all languages that have an understood protocol, HTTP is just a bunch of standards and an understood protocol.

There are a number of different web protocols out there – and you might be familiar with some of them:

  • DNS – Domain Name System
  • FTP – File Transfer Protocol
  • HTTP – Hypertext Transfer Protocol
  • IRC – Internet Relay Chat Protocol
  • SMTP – Simple Mail Transfer Protocol
  • SSL – Secure Sockets Layer

HTTP Status Codes

Now that we understand what the HTTP protocol is, let’s talk about HTTP status codes. Status codes let us know whether the HTTP request was a success, a failure, or something in between.

Let’s take a look at the five core status codes:

  1. 1xx block: informational requests
  2. 2xx block: successful requests
  3. 3xx block: redirects
  4. 4xx block: client errors
  5. 5xx block: server errors

Some status codes are more common than others. For example, when you’re doing digital marketing, you’ll often come across status code 200, status code 301 and status code 404 — but you may never see status code 206 or 307.

Let’s briefly go over each status code block and what they mean.

1xx Status Codes

These are informational requests. The server hasn’t fully completed the request yet and it’s still processing the information. You will not see these codes often. They include:

  • 100 – Continue
  • 101 – Switching protocol
  • 103 – Checkpoints

2xx Status Codes

These are successful requests, which means everything is okay. They include:

  • 200 – OK (you will see this one the most)
  • 201 – Created
  • 202 – Accepted
  • 205 – Reset Content
  • 206 – Partial Content

3xx Status Codes

These are redirects. These are shown when you request an address, but you are sent somewhere else. These can be good or bad. They include:

  • 301 – Moved Permanently
  • 302 – Found
  • 304 – Not Modified
  • 305 – Use Proxy
  • 307 – Temporary Redirect

4xx Status Codes

These are client errors. That means something went wrong with the request (client/user) and not the response (website/ web server). They include:

  • 400 – Bad Request
  • 401 – Unauthorized
  • 403 – Forbidden
  • 404 – Not Found
  • 408 – Request Timeout
  • 410 – Gone
  • 429 – Too Many Requests

5xx Status Codes

These are server errors. That means something went wrong with the response (website/server) and not the request (client/user). They include:

  • 500 – Internal Server Error
  • 502 – Bad Gateway
  • 503 – Service Unavailable
  • 504 – Gateway Timeout

In Conclusion

Looking for more on a particular status code? We have a series of short guides on every HTTP response, so you can optimize your digital marketing strategy. Grab them here:

  • The Complete Status Code Guide
  • Status Code 200, Status Code 301, Status Code 302, Status Code 304
  • Status Code 401, Status Code 403, Status Code 404, Status Code 410
  • Status Code 429, Status Code 500, Status Code 503, Status Code 504

10x Your Traffic from Google.

Get the SEO Checklist sent to your inbox.

[Free Mini-Course] Learn the SEO strategy that we used at PayPal and Airbnb.

Get the EXACT framework you need to implement to get your SEO strategy rock-solid for the rest of year.

Learn the exact SEO Keyword Strategy that we used at PayPal and Airbnb.

Reserve your spot at this special free SEO Masterclass!

SEO training to 10x your traffic from Google.

ClickMinded is where 8,702 startups, agencies, entrepreneurs and students learn SEO, get higher rankings, and more traffic.

Massively grow any business with digital marketing SOPs.

The ClickMinded SOP Library is a collection of digital marketing strategy templates, with step-by-step instructions that you can use to grow any website.

Thank you for being a part of the ClickMinded family!

Понравилась статья? Поделить с друзьями:
  • Ошибка 302 ваз 2115
  • Ошибка 301 302
  • Ошибка 30101 опель зафира б z18xer
  • Ошибка 302 moved temporarily
  • Ошибка 30100 тефаль робот пылесос