A redirect is a way to show search engines new URL instead of the one they previously crawled. Below are descriptions of some of the most commonly used types of redirects.
301 Moved Permanently
301 redirect is a permanent redirect that transfers about 90-99% of the reference weight. This redirect indicates that the page has been moved to the new address and the old url should be considered obsolete.
302 Found (HTTP 1.1) / Moved Temporarily (HTTP 1.0)
302 redirect - temporary redirect. This redirect conveys 0% of the reference weight and, in most cases, should not be used. the Internet works on so called HTTP protocol, which defines how work with URLs. There are 3 versions of this protocol, and server responses have a different response status:
- HTTP 1.0: server responses 302 - “Moved Temporarily” that means URl moved to another URL, but maybe, not permanently .
- HTTP 1.1: server responses 302 - “Found” - the url was found.
307 Moved Temporarily (HTTP 1.1 Only)
A 307 redirect to HTTP 1.1 has become the receiver of a 302 redirect. While the main search bots will begin to consider it as an analogue of 302, for almost all cases, it is best to use 301. The exception to this rule is when the content really moved only temporarily (for example, during maintenance) and search engines already understand That your server is compatible with HTTP 1.1. But, since it is almost impossible to determine whether search engines really understood that your server is compatible with certain protocol, it is better to use 302 redirect for temporarily moved pages.
Other types of redirects
But, it is desirable to use these redirects extremely rarely, as spammers and doorwayers very much like to abuse them. In addition, when using these redirects, the reference weight is almost not transmitted.
Examples of using
To glue a domain from www to without www:
For gluing with no www on with www:
In order to choose on which of the options to glue, it is advisable to look:
- how of these options are more in the top
- for which of the options are there more pages in the index
The canonization of the slash at the end of the url
When designing a site, it is important to decide on one format using a slash at the end of the URL, since for search engines there are 2 URLs like:
are different. Therefore, after you have decided how exactly you will be on the site, then you need to register the following redirects
To remove the slash at the end:
To add a slash to the end of the address bar:
Redirect one page to another page:
Redirect for duplicates of the main page
This code ensures that any homepage address that includes several versions of the direct link of the page name, for example, default.htm or index.html, will be redirected to the canonical homepage, http://www.site.com:
If your directory structure is displayed in the url-le, then if you do recatalogization, the url will change accordingly. In this case, you must register the following redirect:
But, if the url of the old catalog begins immediately after the domain: www.site.com/old-catalog/, then you need to use the following code
Redirect when changing the file extension
If you moved to another CMS and only the extension of the url was changed, then this redirect will help you
Examples of use to protect the site from multiple duplicate pages
Redirect from different domains and subdomains
If you purchased several domains or developed a new site on a subdomain, and forgot to close this subdomain from indexation, then you need to redirect to the main domain:
Thus, all domains of type www.site.ru, www.site.net, test.site.com will be redirected to the site www.site.com.
How to remove some slashes / dashes in urla
Sometimes “by accident” in urla may appear in several slashes, for example, www.site.com/catalog////page-1.html. In these, you need to make a 301 redirect to a page with one slasher www.site.com/catalog/page-1.html:
Similarly, you can glue together several hyphens in one URL: from www.site.com/catalog/page-1.html to www.site.com/catalog/page-1.html:
How to redirect from any URL to url only in lowercase
Since, by search engines, the case of letters is taken into account, then when designing a site, it is desirable that all URLs be in lower case. if you missed the moment, it is best to use the following code for a redirect at the level of a php script:
The optimal strategy for moving to a new domain, taking into account the wishes of the two main search engines on Yandex and Google, is:
- page 301 redirect from the old site to the new one.
- while for the robots.txt file, the redirect is not done, but we write the Host directive to the new domain in it.
Then the code for setting up a redirect on the old site might look like this:
Generation of 301 redirects
If you are not very technically savvy, you can use the services of generating basic redirects:
On such online sites, you can paste your data and receive ready code for redirects.
How to check 301 redirect
After each change in the operation logic of the 301 redirect, it is necessary to check the performance of the site:
- Does the site work at all: go to the main page)
- walk through the main sections and pages of the site
You can also use the following services for more thorough checking of redirects development:
Google has many unclear rules in order for it to understand what we wish to say. In a simple situation, here’s how these instructions are understood by search engines:
301 - Hey, Search Engines: my page is no longer here and it has permanently moved to a new page. Please remove the old page from the index and transfer its weight to the new page.
Canonical - Hey, Search Engines (like most search engines): I have several versions of this page (or content), please index only the version of the page that canonical is on. I’ll keep other pages accessible to people so they can see them, but Search Engine, don’t include them in your index and please transfer the weight to my preferred page.
When is it better to use 301 redirects
- Default is the preferred method.
- For pages: if the page is permanently moved or has been replaced with a new address
- For domains: if the site moved to a new domain (sale of the site, rebranding, etc.)
- For 404 pages and pages that has lost its relevance to appropriate content. For example, if a product was deleted, then you can redirect to a similar product, or to the url category to which the product belonged.
When is it better to use rel = "canonical"?
- When 301 redirects cannot be implemented, or their implementation will take too long
- Duplicate content, but you want to keep both pages for people (for example, show different clothing sizes on different URLs)
- Pages with several different urls of essentially one page (for example, sorting a directory, tracking partner links, ...)
- Cross-domains, when both sites are similar, but similar content should be left on each of the domains.
In general, both options allow you to save reference weight and they will be similarly considered by Google. But in general, 301 redirects are the preferred method.
- Any multi-step redirect. If there is a possibility, then it is advisable not to allow multi-step redirects, so that it will work faster and give maximum reference weight.
- Using the wrong type of redirects. When choosing the type of redirect, you must consider the nuances of each of them.
- New internal redirects without changing the links to new urls. After implementing all the redirects on your site, you need to check that each page of your site already refers to a new one and inside the site you have no links to pages from which the redirect occurs.
- Redirect to pages with non-relevant content.
- To use rel = canonical instead 301 redirect.
- Redirect, the end point of which is not the 200th page. The redirect should lead to a properly working page with a 200 server response. Otherwise, it is advisable not to shoot down search robots and give 404 answers.