Detailed instructions for redirects: when and how to use them

This article will help you understand why redirects are required and how to use them. And, I hope, it helps experts better understand each other :)
What are redirects?
They are also used when you need to create a new page to replace an existing one and maintain the website position and traffic at the same time. There are nine types of redirects, but only three of them are actively used in SEO practice:
- 301 Moved Permanently (permanent redirect) indicates that the document has been moved to the new URL forever. When SEO specialists or developers talk about a redirect, they almost always mean a 301-redirect. The old URL disappears from the search results and is replaced by a new one.
- 302 Found, 302 Moved Temporarily (found, moved temporarily) indicates that the document is transferred temporarily, for example, takes the user to the page of the action (sale), without changing the contents of the old page. At the same time, the old page URL remains in the search results, because it has been temporarily moved to the new one.
- 307 Temporary Redirect means that the requested document is available for a short time at a different URL while retaining the request transmission method (GET, POST). Basically, it performs the same task as the 302-redirect.
General tips for setting up redirects
The more relevant the acceptor page (the one that accepts the redirect) to the donor page, the faster they will stick together, and the more weight it will transfer.
2. Avoid using a redirect where you can set a rel = canonical
If the content of the pages is duplicated, but it's important for you to leave the pages accessible to users, use rel = canonical instead of a redirect. For example, if there are several versions of the content (for printing, mobile, etc.)
3. Don't use redirects for robots.txt
It's important when changing a domain or moving to a secure protocol; the old robots.txt is accessible to robots, so domains are stick together faster.
4. Avoid two, three or more redirects in a row
Each new redirect means loss of load time, extra load on the server, and possible loss of the transmitted page weight.
5. First use page redirects with a higher level of nesting in the .htaccess file, for example:
- first goes the redirect from site.com/category-1/subcategory-1/ to site.com/category-1/subcategory-2/;
- then from site.com/category-0/ to site.com/category-0;
- and the last go global rules such as redirecting all pages without "/" to pages with "/".
6. Browsers cache redirects: reset cache or use specialized services to check their operation.
Some SEO-experts advise you first to configure 302-redirects, and after the newest pages appear in search results, change it to 301 in order to exclude the possibility of losing traffic.
Please be warned that such a use of the 302-redirect is contrary to the recommendations of Google, but no one forbids you to do experiments :)
In Serpstat, you can see redirects in two ways: in the summary report and in the personal report.

.htaccess syntax and characters
. — dot means any character;
[abc] - a list of characters matching the letters a, b, or c;
[^ abc] - a list of characters that are not in the range. The condition matches any character except a, b, c;
* - the previous character can be repeated 0 or more times;
[abc] * - find characters from a given set, going in a row;
[^ abc] * - inverse operation;
. * - replacement of any character set;
".*" — find all substrings between quotation marks.
^ - indicates the beginning of a line (when used at the beginning of an expression);
$ - end of a line;
\ w - letter, number or underscore _;
\ d - any digit;
\ D - any character except digits;
[0-9] — an indication of any digit;
[a-z] - an indication of any letter from a to z with the lower case;
[A-Z] - an indication of any letter from A to Z with the upper case;
[a-zA-Z] - any letter from a to Z, the case is not important;
[a-Z] - the same thing, only shorter.
Flags for additional options
NC - NoCase disables character case checking when a rule is triggered.
R - Redirect stops the URL change and returns the result.
L - Last stops the creation of the URL, and the line is considered final.
301-redirect: .htaccess examples
RewriteCond %{HTTP_HOST} ^site\.com$ [NC]
RewriteRule ^(.*)$ http://www.site.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.site\.com$ [NC]
RewriteRule ^(.*)$ http://site.com/$1 [R=301,L]
— http://www.site.com/dog1
If the page URL differs by at least one character, search engines consider such pages to be different. And if these are different pages with the same content, then they are duplicates.
Therefore, it's extremely important to ensure that all page URLs are only lowercase and of the same format (with a slash or without a slash at the end). As in the case with www, set up redirects to the version of pages with which you have more in the index.
RewriteCond %{HTTP_HOST} (.*)
RewriteCond %{REQUEST_URI} /$ [NC]
RewriteRule ^(.*)(/)$ $1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*[^/])$ $1/ [L,R=301]
$lowerURI=strtolower($_SERVER['REQUEST_URI']);
if($_SERVER['REQUEST_URI']!=$lowerURI)
{
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://" . $_SERVER['HTTP_HOST'] . $lowerURI);
exit();
}
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule !(^$|.*\.(css|jpg|gif)) / [R=301,L]
RewriteCond %{HTTPS} =of
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
You need to understand that when setting up redirects to https, the ability to send http requests to the website is still activated. HSTS tells the browser not to "communicate" with the website through http.
Even if the browser encounters an http link on this website, or the user enters it manually, he will send the request immediately to the https version and will not go the way when the request is sent first to the http version, and only then the server itself uses a 301redirect to https. This is done to protect the user from possible wedges and redirects of cool hackers and intruders. Search bots will not fall under this scenario.
RewriteRule ^catalog /catalog-new/$1 [R=301,L]
Redirect 301 /oldpage.html http://site.com/newpage.html
RewriteCond %{REQUEST_URI} ^(.*)--(.*)$
RewriteRule . %1-%2 [R=301,L]
RewriteCond %{QUERY} ^IBLOCK_ID=4&SECTION_ID=20$ [NC]
RewriteRule ^catalog/index\.php$ /newcatalog/? [R=301,L]
RewriteCond %{QUERY} ^IBLOCK_ID=4&SECTION_ID=(.*)$ [NC]
RewriteRule ^catalog/index\.php$ /catalognew/? [R=301,L]
RewriteRule ^category/$ http://site.com/new-category/ [R=301,L]
302 and 307-redirect: how to use it correctly
- It's important that the original page continues to be indexed. For example, you have an online store, and some product has ended, but there is a very close analogue of it. Then, while the product is out of stock, you can redirect users to the page with its analogue.
- The landing page will frequently change. For example, for requests such as "concerts in NY today," you can make 302-redirects to a page with the current date on the website every day.
- Links are placed on the original page, which should be further indexed.
For search engines, a 307-redirect is an almost complete prototype of 302.
The only difference is that the 307-redirect saves the request transmission method, while 302 can behave unpredictably with methods other than GET (i.e., POST, PUT, DELETE).
How to quickly find excessive redirects on a website
Serpstat website audit works on the same principle as a search robot. The examination will indicate the weaknesses of your website in which it doesn't meet the requirements of search engines, including the redirect chain, and also suggests ways to eliminate these errors.
In order to check the website for errors, you must first create a project and make the appropriate settings.
After the examination is completed, you will receive a selective summary of the errors. All SEO vulnerabilities will be prioritized: from high, i.e., errors that threaten positions, to low, i.e., errors that are less dangerous but require correction.

There is also a unique tool available in Serpstat, which is a "One Page Audit". Using it, you can check for technical problems not the entire website, but only certain URLs. This tool saves time and user limits, helping to track the effectiveness of SEO optimization.
Conclusion
- if you need to permanently change the page or transfer the link weight you can use 301-redirects;
- if the landing page changes frequently or redirects for a short time use a 302-redirect;
- if the request transmission method is not GET, and it's important for you to process it correctly, use 307-redirects instead of 302.
Speed up your search marketing growth with Serpstat!
Keyword and backlink opportunities, competitors' online strategy, daily rankings and SEO-related issues.
A pack of tools for reducing your time on SEO tasks.
Cases, life hacks, researches, and useful articles
Don’t you have time to follow the news? No worries! Our editor will choose articles that will definitely help you with your work. Join our cozy community :)
By clicking the button, you agree to our privacy policy.