SEO redirects need to be used correctly because they affect how Google finds and indexes websites.
While most people think of redirects as a sign of an internet detour, there’s a lot more going on, and it’s surprisingly pleasant to discover.
Continue reading for a comprehensive overview of redirects and their respective applications for technical SEO.
What Is A Redirect?
Site redirects tell browsers and search engines information about a URL and where to find a web page.
A URL redirect involves code implemented on a specific URL or group of URLs so that the user (or search engine) is sent to a different page from the actual URL that was entered or clicked.
When To Use Redirects
The main reasons for using redirects are:
For SEO purposes, URL redirects are important because:
Redirects can be implemented on a group or domain basis, but often need to be set up on an individual basis to avoid problems.
Using RegEX for group redirects can have unexpected results if your logic isn’t flawless!
Types Of Redirects
There are three main types of redirects:
What Is A HTTP Response Status Code?
Browsers and search engine crawlers like GoogleBot are called user agents.
When a user agent tries to access a web page, what happens is that the user agent sends a request and the website server issues a response.
The response is called the HTTP response status code. Provides status for a URL request.
In the event that a user agent such as GoogleBot requests a URL, the server provides a response.
For example, if the URL request is successful, the server will provide a response code of 200, which means that the URL request was successful.
So when you think of a GoogleBot reaching a website and trying to crawl it, what’s happening is a series of requests and responses.
HTTP Redirects
An HTTP redirect is the server’s response to a URL request.
If the URL exists at another URL (because it has been moved), the server tells the user agent that the URL request is redirected to another URL.
The response code for a changed URL is usually in the form of a 301 or 302 response status code.
The entire series of 3xx response codes communicates a lot of information that can be acted upon by the user agent if desired.
An example of an action a user agent can take is to cache the new URL so that the next time the old URL is requested, it will request the new URL instead.
So 301 and 302 redirects are more than an Internet road sign that says, “Go here, not there.”
3XX Series Of Status Codes
Redirects are more than just the two status codes we all know, the 301 and 302 response codes.
There are a total of seven official 3xx response status codes.
These are the different types of redirects available for use:
Some of the above status codes have not been around that long and you may not use them. So before you use any redirect code that isn’t a 301 or 302, make sure the intended user agent can interpret it.
Since GoogleBot is using the latest version of Chrome (called the headless browser), it’s easy to check if the status code is compatible by checking if Chrome recognizes the status code using the browser’s compatibility list.
For SEO, you should stick to the 301 and 302 response codes, unless there is a specific reason to use one of the other codes.
301: Moved Permanently
The 301 status code is regularly referred to as 301 redirects. But the official name is 301 Moved Permanently.
A 301 redirect indicates to the user agent that the URL (sometimes called the destination resource or simply the resource) has been changed to a different location and that it should use the new URL for future requests.
As mentioned earlier, more information is also available.
The 301 status code also suggests to the user agent:
This last point is a technical problem. According to the official standards for the 301 status code:
“Note: For historical reasons, the user agent MAY change the request method from POST to GET for the next request. If this behavior is not desired, you can use the 308 (Permanent Redirect) status code instead.”
For SEO, when search engines see a 301 redirect, they pass the ranking of the old page to the new one.
Before making a change, you should be careful about using a 301 redirect. 301 redirects should only be used if the change to a new URL is permanent.
You should not use the 301 status code if the change is temporary.
Also, if you later change your mind and go back to the old URL, the old URL may no longer rank and may take some time to regain rank.
The main thing to remember is that a 301 status code will be used when the change is made permanent.
302: Found
The main thing to understand about the 302 status code is that it is useful in cases where the URL has been temporarily changed.
The meaning of this response code is that the URL is temporarily at a different URL, so it is suggested to use the old URL for future requests.
The 302 redirect status code also has a technical caveat related to GET and Post:
“Note: For historical reasons, the user agent MAY change the request method from POST to GET for the next request. If this behavior is not desired, you can use the 307 (temporary redirect) status code instead.”
References to “historical reasons” may refer to old user agents or user agents with errors that may change the request method.
307: Temporary Redirect
A 307 redirect means that the requested URL has been temporarily moved and the user agent should use the original URL for future requests.
The only difference between a 302 and a 307 status code is that the user agent must request a new URL with the same HTTP request used to request the original URL.
This means that if a user agent requests a page with a GET request, the user agent must use a GET request for the new temporary URL and cannot use a POST request.
The Mozilla 307 status code documentation explains this more clearly than the official documentation.
“The server sends this response to direct the client to retrieve the requested resource at a different URI using the same method used in the previous request.
This has the same semantics as the HTTP 302 Found response code, with the exception that the user agent must not change the HTTP method used: if POST was used in the first request, POST must be used in the second request.”
Except for the 307 status code, which requires that subsequent requests be of the same type (POST or GET) and that the 302 can go either way, everything else is the same between the 302 and 307 status codes.
302 Vs. 307
Redirection can be managed via .htaccess server configuration files on Apache, example.conf file on Nginx, or via plugins if you are using WordPress.
In all cases, they have the same syntax for writing redirection rules. They differ only in the commands used in the configuration files. For example, a redirect to Apache will look like this:
(You can read about symbolic links here.)
On Nginx servers it will look like this:
The commands used to report the redirect server status code and the action command are different.
However, the redirect syntax ( ^/oldfolder/ /newfolder/ ) is the same for both.
On Apache, make sure the mod_rewrite and mod_alias modules (responsible for handling redirects) are enabled on your server.
Since Apache is the most widely used type of server, here are examples of apache .htaccess files.
Make sure your .htaccess file has these two lines above the redirect rules and place the rules below them:
Read the official documentation to learn more about RewriteEngine.
To understand the examples below, you can refer to the RegExp basics table below.
How To Create Redirects
How To Create A Redirect For A Single URL
The most common and frequently used type of redirection is to delete pages or change URLs.
Let’s say you changed the URL from /old-page/ to /new-page/. The redirection rule would be:
The only difference between the two methods is that the former uses the Apache module mod_rewrite and the latter mod_alias. This can be done using both methods.
The regular expression “^” means that the URL must start with “/old-page”, while (/?|/.*)$ indicates that everything following “/old-page/” with a slash “/” or no exact match should be redirected to /new page/.
You could also use (.*), ie. ^/old-page(.*) but the problem is that if you have another page with a similar url like /old-page-other/ it will also be redirected when we just want to redirect /old-page/ .
The following URLs will match and redirect to the new page:
It will redirect each version of the page URL to the new one. If we use a redirect in the following form:
Without regular expressions, all URLs with a UTM query string, e.g. /old-page?utm_source=facebook.com (which is common since URLs are used to share via the social network) ended up as a 404.
Even the /old page without the trailing slash “/” would end up as a 404.
Redirect All Except
Suppose we have a bunch of URLs like /category/old-subcategory-1/, /category/old-subcategory-2/, /category/final-subcategory/ and we want to merge all subcategories into /category/final-subcategory / . Here we need an “all but” rule.
Here we want to redirect everything under /category/ on the third line, unless /category/final-subcategory/ is on the fourth line. In the second line, we also have the “!-f” rule, which ignores any files such as images, CSS or JavaScript files.
Otherwise, if we have some assets like “/category/image.jpg”, that will also be redirected to “/final-subcategory/” and cause the image to break.
Directory Change
You can use the rule below if you’ve done a category restructure and want to move everything from the old directory to the new one.
I used $1 in the target to tell the server to remember everything in the URL that follows /old-directory/ (ie /old-directory/subdirectory/) and pass that (ie “/subdirectory/”) to the goal. As a result, it will be redirected to /new-directory/subdirectory/.
I used two rules: one without the trailing slash and one with the trailing slash.
I could combine them into one rule using (/?|.*)$ RegExp at the end, but it would cause problems and add a slash “//” to the end of the URL when the requested URL has a query string without a trailing slash (ie. “/old-directory?utm_source=facebook” would be redirected to “/new-directory//?utm_source=facebook”).
Remove A Word From URL
Let’s say you have 100 URLs with the city name “Chicago” on your site and you want to remove them.
For the URL http://yourwebiste.com/example-chicago-event/ the redirect rule would be:
If the example URL is of the form http://yourwebiste.com/example/chicago/event/, the redirect would be:
Set A Canonical URL
Having canonical URLs is the most important part of SEO.
If it’s missing, you can put your site at risk of duplicate content issues because search engines treat URLs with “www” and “non-www” versions as different pages with the same content.
Therefore, you should ensure that you run the site with only one version of your choice.
If you want to run your website with the “www” version, use this rule:
The trailing slash is also part of canonicalization, as URLs with or without a trailing slash are also treated differently.
This will ensure that /example-page is redirected to /example-page/. You may choose to remove the slash instead of adding it, then you’ll need another rule below:
HTTP To HTTPS Redirect
Following Google’s initiative to encourage website owners to use SSL, switching to HTTPS is one of the commonly used redirects that almost every website has.
You can use the rewrite rule below to force HTTPS on every site.
This allows you to combine a www or non-www version redirect into a single HTTPS redirect rule.
Redirect From Old Domain To New
This is also one of the most commonly used redirects when you decide to rebrand and need to change your domain. The rule below redirects old-domain.com to new-domain.com.
It uses two examples: one with the “www” version of URLs and one with “no www” because any page can have incoming links to both versions for historical reasons.
Most website owners use WordPress and may not need a .htaccess file for redirects, but use a plugin instead.
The handling of redirects using plugins may differ slightly from what we discussed above. You may need to read their documentation for correct RegExp processing for a specific plugin.
Of the existing ones, I would recommend a free plugin called Redirection, which has a lot of parameters to control redirection rules and a lot of useful documents.
Redirect Best Practices
1. Don’t Redirect All 404 Broken URLs To The Homepage
This example often happens when you are too lazy to research your 404 URLs and map them to the appropriate landing page.
They are all still treated as 404s according to Google.
Yeah, it’s not a good practice (it confuses users) and we mostly treat them as 404s anyway (they’re soft 404s), so there’s no advantage. Not critically broken/bad, but extra complexity for no good reason – better make a better 404 page.
— 🍌 John 🍌 (@JohnMu) January 8, 2019
If you have too many pages like this, you should consider creating beautiful 404 pages and displaying search options to encourage users to browse further or find something other than what they were looking for.
Google strongly recommends that the content of the redirected page should be equivalent to the old page. Otherwise, such a redirect can be considered a soft 404 and you will lose the ranking of this page.
2. Get Mobile Page-Specific Redirects Right
If you have different URLs for your desktop and mobile sites (ie “example.com” for desktop and “m.example.com” for mobile), make sure to redirect users to the appropriate page for the mobile version.
Correct: “example.com/sport/” to “m.example.com/sport/” Incorrect: “example.com/sport/” to “m.example.com”
You also need to ensure that if one page has a 404 on desktop, it should also have a 404 on mobile.
If you don’t have a mobile version for your page, you can avoid redirecting to the mobile version and keep them on the desktop page.
3. How To Use Meta Refresh
It is possible to perform a redirect with a refresh meta tag like the example below:
<meta http-equiv=”refresh” content=”0;url=http://example.com/new-page/” />
If you insert this tag in /old-page/, the user will be immediately redirected to /new-page/.
Google does not prohibit this redirection, but it does not recommend it.
Redirecting the meta refresh type should work. We don’t recommend it for two reasons: UX (keeps page in browser history, afaik) & processing time (we need to parse the page to see it). Once it’s processed, it’s like a redirect.
— 🍌 John 🍌 (@JohnMu) March 2, 2018
According to John Mueller, search engines may not be able to correctly recognize this type of redirect. The same goes for JavaScript redirects.
4. Avoid Redirect Chains
This message appears when you have a regular expression set incorrectly and ends up in an infinite loop.
Screenshot by the author, December 2022
This usually happens when you have a referral chain.
Let’s say you redirected page 1 to page 2 a long time ago. Maybe you forgot that page 1 was redirected and decided to redirect page 2 to page 1 again.
As a result, you will end up with a rule like this:
This will create an infinite loop and cause the error shown above.
Conclusion
Knowing what redirects are and which situation requires a specific status code is fundamental to proper website optimization. This is a key part of understanding SEO.
Many situations require an accurate knowledge of redirects, such as moving a website to a new domain or creating a temporary landing page URL for a website that will return to its normal URL.
While a lot can be done with a plugin, plugins can be abused without properly understanding when and why to use a certain type of redirect.
Why do we use 2 >> redirection?
which writes the output of one file to the input of another file. 2>&1 means STDERR redirects to the STDOUT destination (which is a list of file directories). We redirect the error output to standard output, which is then redirected to a list of file directories. Therefore, both outputs are written to the dirlist file.
How to decode an HTML encoded string into JavaScript? Decoding HTML entities using the DOM element’s createElement() method. We then used the innerHTML property to write an array containing the HTML entities inside the text box. This will convert the string to plain text and the entities to characters.
Why do we use   in HTML?
A commonly used entity in HTML is the continuous space: A non-breaking space is a space that does not break on a new line. Two words separated by a continuous space will be concatenated (not wrapped on a new line). This is handy when word breaks can be annoying.
What is & NBSP?
Updated on February 20, 2020. In computer programming, NBSP stands for: continuous space. This is an HTML character that you may have seen online. It can appear as ” ” and tells the web browser to create a space between two words without going to the next line.
What is HTML &?
Save this answer. Show activity on this post. & is HTML for “Start of character reference”. & is a reference to the sign for “An ampersand”. &Currently; not a standard character reference and also an error (browsers may try to recover from the error, but you shouldn’t rely on it).
What does > mean?
> means a character greater than: > ≤ means less than or equal sign: ⤠≥ means a sign greater than or equal to: â¥
How do I mention a character in XML?
In XML, character and entity references are formed by surrounding a numeric value or name with & and ; âfor example © is a decimal character reference and © is an entity reference.
What characters are allowed in XML?
XML 1.0
- U 0009, U 000A, U 000D: these are the only C0 controls accepted in XML 1.0;
- U 0020âU D7FF, U E000âU FFFD: this excludes some (not all) non-characters in BMP (all substitutions, U FFFE and U FFFF are forbidden);
- U 10000âU 10FFFF: this includes all code points in additional planes, including non-characters.
How to replace HTML special characters in JavaScript?
Use replace() in JavaScript to replace special characters.
How to convert HTML special characters in JavaScript?
A JavaScript-based solution Another way is to convert each special character to the corresponding HTML code using JavaScript. Inside the script, we will replace all special documents using a regular expression, which is â&#â½ the ASCII value of the â;â character.
How to replace special character in JavaScript?
The JavaScript replace() method is used to replace all special characters from a string with _ (underscore), which is described below: replace() method: This method searches a string for a specified value or regular expression and returns a new string with the replaced defined value.
What are the four 4 types of redirecting children?
In this module, we looked at four ways to use redirection: verbal, physical, cued, or proximal attention.
What is child diversion? Redirection is a technique that parents can use to help children understand what is appropriate behavior and how to manage their behavior. Diversion is used to encourage desired behavior, prevent injury, reduce punishment, and encourage learning and exploration.
What is redirection and its types?
What is redirection? A redirect is a way to send users and search engines to a different URL than the one they originally requested. The three most commonly used redirects are 301, 302 and Meta Refresh.
How many types of redirects are there?
There are several types of redirects, classified into three categories: Permanent redirects. Temporary diversions. Special diversions.
What is the redirection definition?
transitive verb. : to change course or direction.
What are redirection strategies?
Redirection is a proactive teaching strategy used to address challenging behavior (something that interferes with learning and engaging in prosocial interaction) BEFORE it escalates or continues. Redirection: Allows the teacher to guide children to alternative behaviors that are more acceptable.
What is a positive redirection strategy?
With a calm tone, neutral body language, and clear, concise text, you capture your students’ attention without being overwhelming. You tell students exactly what they are doing wrong and what they should do instead in as few words as possible, leaving less room for confusion.
What are examples of redirection?
Physically redirecting the child away from the electrical outlet to a safe toy for play. Accompanying the child from the bathroom to the living room and involving the child in the game. Take away a dangerous object from a child and replace it with a safer one.
What is an example of redirecting?
Redirection takes a negative situation and turns it into a positive one. In the example above, a form of redirection would be to sit down with your child and say, “I see you’re having trouble getting this building to stand. Why don’t you try building a zoo or a park instead?”
What is the meaning of redirecting?
/ËriË.daɪËrekt/ /ËriË.dɪËrekt/ to change the direction of something, especially to send a letter to a new address: Funds must be redirected to many underfunded areas of education. . Please forward all mail coming for me to my address in Ottawa.
What are examples of redirection?
Physically redirecting the child away from the electrical outlet to a safe toy for play. Accompanying the child from the bathroom to the living room and involving the child in the game. Take away a dangerous object from a child and replace it with a safer one.
Can I use DNS to redirect URL?
URL Redirections To set up URL forwarding, you can change the DNS record for a domain name to point to a different web address. When users visit the original URL, DNS redirects to the new URL. There are two types of URL redirection: permanent and temporary.
How do I redirect a URL? Click the URL Redirects tab. In the upper right corner, click Add URL Redirects. In the right panel, select Standard or Flexible redirect type. A standard redirect is used to redirect one URL to another.
What should I use for redirect URL?
A redirect is a way to send users and search engines to a different URL than the one they originally requested. The three most commonly used redirects are 301, 302 and Meta Refresh.
How do I do a redirect on a URL?
In the Domain category, select the Redirects menu. You will see the Create Redirect section. Here you will need to fill in which URL you want to redirect and where you want to redirect. Verify that your information is correct and select the correct connection protocol â HTTP or HTTPS.
What is a redirect URL example?
A redirect is when a website visited at a particular URL changes to another URL. For example, a person visits âwebsite.com/page-aâ in their browser and is redirected to âwebsite.com/page-bâ instead.
How long does a URL redirect take?
Normally, changes should take effect within 30 minutes.
How long does DNS redirection take? DNS propagation is the time frame it takes for DNS changes to be updated across the Internet. A change to a DNS record—for example, changing the IP address defined for a particular hostname—can take up to 72 hours to propagate globally, although it usually takes a few hours.
How long does a 301 redirect last?
Google says that a 301 redirect should be maintained for at least a year to ensure permanent change recognition.
How long does it take for 301 redirects to work?
After you have completed all the necessary steps, it can take up to 72 hours for the domain name to spread across the Internet.
How long does it take for Google to recognize a 301 redirect?
If your site is crawled faster, Google can crawl and index your 301s faster. I would normally wait a few weeks for it to be fully implemented. It is not necessary that all URLs will be crawled at the same time. What is the difference between 301 and 302 redirects?
How long does it take for a redirect to propagate?
Normally, DNS changes propagate within a few hours, but it can take up to 48 hours for everything to propagate across the Internet. Many things affect propagation time, including your TTL, your ISP, and your domain registrar.
How long should a redirect take?
Google Webmaster Trends analyst John Mueller said that 301 redirects used for permanent page migrations should be active for a long time. He explained that it takes at least six months to about a year for Google to fully recognize that your site has been moved.
How long do redirects take to work in Google?
Then it’s as simple as entering the URL to be 301 redirected to and the destination URL and then click Save. A 301 redirect can be done in less than 10 seconds.
How long should a redirect take?
Google Webmaster Trends analyst John Mueller said that 301 redirects used for permanent page migrations should be active for a long time. He explained that it takes at least six months to about a year for Google to fully recognize that your site has been moved.
How long do you have to keep redirects in place?
Best practice is to implement 301 redirects from previous URLs to new ones when moving pages and leave them active for at least 1 year. When moving entire domains to new domains, keep them active for as long as reasonably possible.
How long does it take for 301 redirects to work?
After you have completed all the necessary steps, it can take up to 72 hours for the domain name to spread across the Internet.
What is an SEO redirect?
SEO stands for Search Engine Optimization. A redirect is a term that describes the act of forwarding one URL to another URL. Redirecting a page usually means assigning a completely new URL to the page. The redirect is quite simple and is used frequently, most of the time without the site visitors knowing.
What are the 4 types of redirects? Types of redirects
- 301 Permanent.
- 302 Found.
- 307 Temporary.
Why redirect SEO?
There are two reasons why you should use redirects when moving content: Better user experience for visitors â You don’t want visitors to receive a âpage not found warning when they try to access a page that has been moved. Redirects solve this problem by seamlessly sending visitors to a new content location.
What is the purpose of redirect?
What is redirection? A redirect is a way to send users and search engines to a different URL than the one they originally requested. The three most commonly used redirects are 301, 302 and Meta Refresh.
Why is 301 redirect important for SEO?
A 301 signals a permanent redirect from one URL to another, meaning that all users requesting the old URL will automatically be sent to the new URL. A 301 redirect transfers all the ranking power from the old URL to the new URL and is most commonly used when a page has been permanently moved or removed from a website.
What is an example of redirect?
A redirect is when a website visited at a particular URL changes to another URL. For example, a person visits âwebsite.com/page-aâ in their browser and is redirected to âwebsite.com/page-bâ instead.
How does redirect work?
Redirects work much the same for search engines. They send search engines from one specific URL to another. Website owners often set up redirects for pages that are broken, contain duplicate content, or have been moved to new URLs. Thus, users and search engines access the most relevant or current page.
When would you use a redirect?
Redirects are used when moving content to a new URL, when deleting pages, or when changing domain names or merging websites. Avoid using redirects if possible. When you must use them, consider these best practices: Avoid chained redirects: One redirect should not feed another redirect.
What is 301 and 302 redirect in SEO?
While a 301 redirect means that the page has been permanently moved to a new location, a 302 redirect means that the move is only temporary. Continue reading to learn more. There are two redirects that can be used to direct website users and search engines to a different URL than the one they originally intended to visit.
What is 301 redirect in SEO?
A 301 signals a permanent redirect from one URL to another, meaning that all users requesting the old URL will automatically be sent to the new URL. A 301 redirect transfers all the ranking power from the old URL to the new URL and is most commonly used when a page has been permanently moved or removed from a website.
Is 302 redirect good for SEO?
When used correctly, 302 redirects won’t hurt your SEO efforts. When you choose this type of redirect, the original page remains indexed by Google and no value (link) is transferred to the new URL because Google knows it’s only temporary.
