Redirects for SEO must be used correctly because they affect how websites are crawled and indexed by Google.
While most people think of redirects as a diversion signal on the internet, there’s a lot more going on, and it’s surprisingly fun to find out.
Read on for a complete overview of redirects and proper application for technical SEO.
What Is A Redirect?
Contents
- 1 What Is A Redirect?
- 2 When To Use Redirects
- 3 Types Of Redirects
- 4 What Is A HTTP Response Status Code?
- 5 HTTP Redirects
- 6 3XX Series Of Status Codes
- 7 How To Create Redirects
- 8 Redirect Best Practices
- 9 Conclusion
- 10 Do redirects affect site speed?
- 11 Does Google penalize for redirect?
- 12 Which is most effective SEO techniques?
- 13 Why are redirects used?
Website redirects tell browsers and search engines information about a URL and where to find the webpage.
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 page other than the actual URL that was entered or clicked on.
When To Use Redirects
The main reasons to use redirects are:
For SEO purposes, URL redirects are important because:
Redirects can be implemented on a group or domain-wide basis, but often need to be set up on an individual basis to avoid problems.
When using RegEX for group redirects, it can have unexpected results if the 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 makes a request and the website server issues a response.
The response is called the HTTP response status code. Provides a status for requesting a URL.
In the situation where a user agent like GoogleBot requests a URL, the server provides a response.
For example, if a URL request is successful, the server will return a response code of 200, which means that the URL request was successful.
So when you think of a GoogleBot reaching into a website and trying to crawl it, what’s happening is a series of requests and responses.
HTTP Redirects
An HTTP redirect is a server response to request a URL.
If the URL exists at a different URL (because it was moved), the server tells the user agent that the URL request is redirected to a different URL.
The response code for a modified URL is usually in the form of a 301 or 302 response status code.
The entire 3xx set of response codes communicates a lot of information that the user agent can optionally act on.
An example of an action the user agent can take is to save a cache of the new URL so that the next time the old URL is requested, it will request the new URL instead.
So, a 301 and 302 redirect is more than an Internet traffic sign that says “Go here, not there.”
3XX Series Of Status Codes
Redirects aren’t just the two status codes everyone is familiar with, 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 you to use:
Some of the above status codes have not been around for a long time and may not be used. So, before using any redirect code other than 301 or 302, make sure the intended user agent can interpret it.
Since the GoogleBot uses the latest version of Chrome (called a headless browser), it’s easy to check if a status code is compatible by checking if Chrome recognizes the status code with a browser compatibility list.
For SEO, you should stick to using 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 usually referred to as 301 redirects. But the official name is 301 Moved Permanently.
The 301 redirect tells a user agent that the URL (sometimes referred to as the target resource or simply resource) has changed to another location and that it should use the new URL for future requests.
As mentioned above, there is even more information.
The 301 status code also prompts the user agent:
This last point is a technical problem. According to the official standards for the 301 state code:
“Note: For historical reasons, a 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 need to be careful when using a 301 redirect. 301 redirects should only be used when changing to a new URL is permanent.
Status code 301 should not be used when 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 it may take some time to regain ranking.
So, the main thing to remember is that a 301 status code will be used when the change is permanent.
302: Found
The main thing to understand about the 302 status code is that it’s useful for situations where a URL is temporarily changed.
The meaning of this response code is that the URL is temporarily at a different URL and it is recommended that you use the old URL for future requests.
The 302 redirect status code also includes a technical warning about GET and Post:
“Note: For historical reasons, a 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.
Reference to “historical reasons” may refer to old or faulty user programs that could change the request method.
307: Temporary Redirect
A 307 redirect means that the requested URL is moved temporarily and the user agent must use the original URL for future requests.
The only difference between a 302 and 307 status code is that a user agent must request the new URL with the same HTTP request used to request the original URL.
This means that if the user agent requests the page with a GET request, the user agent must use a GET request for the new temporary URL and cannot use the POST request.
Mozilla’s 307 status code documentation explains this more clearly than the official documentation.
“The server sends this response to direct the client to obtain the requested resource at another URI with 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 a POST was used in the first request, a POST must be used in the second request.
Other than 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
You can manage a redirect via the .htaccess server configuration files on Apache, the example.conf file on Nginx, or via plugins if you’re using WordPress.
In all cases, they have the same syntax for writing redirect rules. They differ only with the commands used in the configuration files. For example, a redirect on Apache would look like this:
(You can read about symbolic links here.)
On Nginx servers, it will look like this:
The commands used to indicate the server redirect status code and the action command differ.
But the redirect syntax ( ^/oldfolder/ /newfolder/ ) is the same for both.
On Apache, make sure that the mod_rewrite and mod_alias modules (responsible for handling redirects) are enabled on your server.
Since the most popular server type is Apache, here are some examples of Apache .htaccess files.
Make sure the .htaccess file has these two lines above the redirect rules and enter the rules below them:
Read the official documentation to learn more about the RewriteEngine.
To understand the examples below, you can refer to the table below on RegExp Basics.
How To Create Redirects
How To Create A Redirect For A Single URL
The most common and widely used type of redirect is when deleting pages or changing URLs.
For example, suppose you changed the URL from /old-page/ to /new-page/. The redirect rule would be:
The only difference between the two methods is that the first uses the mod_rewrite Apache module and the second uses mod_alias. It can be done using both methods.
The regular expression “^” means that the URL must begin with “/old-page” while (/?|/.*)$ indicates that everything following “/old-page/” with a slash “/” or without an exact match it must be redirected to /new-page/.
We could also use (.*), i.e. ^/old-page(.*), but the problem is, if you have another page with a similar URL like /old-page-other/, it will also redirect when we just want redirect /old-page/.
The following URLs will match and take you to a new page:
It will redirect any change of the page URL to a new one. If we use the redirect in the following form:
Without regular expressions, all URLs with UTM query string, such as /old-page?utm_source=facebook.com (which is common since URLs are used to be shared on a social network), would end up as 404.
/old-page without a trailing slash “/” would also end up as 404.
Redirect All Except
Let’s say 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/ . We need the “everyone but” rule here.
Here, we want to pipe everything under /category/ on the third line except if it’s /category/final-subcategory/ on the fourth line. We also have the “!-f” rule on the second line, ignoring any files such as images, CSS or JavaScript files.
Otherwise, if we have resource like “/category/image.jpg” it will also redirect to “/final-subcategory/” and cause a broken image.
Directory Change
You can use the rule below if you have 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 that it should remember everything in the URL following /old-directory/ (ie, /old-directory/subdirectory/) and pass it (ie, “/subdirectory/”) to the target. As a result, it will be redirected to /new-directory/subdirectory/.
I used two rules: one capitalized with no trailing slash and the other with a 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 without trailing slash has a query string (for example , “/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 on your website with the city name “Chicago” 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 in the format 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 missing, you could endanger your website with duplicate content issues because search engines treat URLs with “www” and “non-www” versions as different pages with the same content.
Therefore, you need to make sure that you are only running the website with a version of your choice.
If you want to run your website with the “www” version, use this rule:
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 can choose to remove the bar instead of adding, so you’ll need the other rule below:
HTTP To HTTPS Redirect
After Google’s initiative to encourage website owners to use SSL, migrating to HTTPS is one of the commonly used redirects by almost all websites.
The rewrite rule below can be used to force HTTPS on every website.
Using this, you can combine a www or non-www version redirect into an HTTPS redirect rule.
Redirect From Old Domain To New
This is also one of the most used redirects when you decide to rebrand and need to change your domain. The following rule redirects old-domain.com to new-domain.com.
Use two cases: one with the “www” version of the URLs and another “non-www” because any page for historical reasons can have inbound links to both versions.
Most site owners use WordPress and may not need an .htaccess file for redirects, but use a plugin instead.
Handling redirects through plugins might be a little different than discussed above. You may need to read their documentation to properly handle RegExp for your specific plugin.
Among the existing ones, I would recommend a free plugin called Redirect, which has many parameters to control redirect rules and many useful documents.
Redirect Best Practices
1. Don’t Redirect All 404 Broken URLs To The Homepage
This case often occurs when you are too lazy to go through your 404 URLs and map them to the appropriate landing page.
According to Google, they are all still treated as 404s.
Yeah, that’s not a good practice (it confuses users), and we mostly treat them as 404s anyway (they’re soft-404s), so there’s no benefit. It’s not critically broken/bad, but added complexity for no good reason – it makes for a better 404 page instead.
— 🍌 John 🍌 (@JohnMu) January 8, 2019
If you have too many pages like this, you should consider building beautiful 404 pages and engaging users to browse further or find something other than what they were looking for by displaying a search option.
It is strongly recommended by Google that the content of the redirected page is equivalent to the old page. Otherwise, that redirect could be considered a soft 404 and you will lose that page’s rank.
2. Get Mobile Page-Specific Redirects Right
If you have different URLs for desktop and mobile websites (e.g. “example.com” for desktop and “m.example.com” for mobile), you need to make sure you redirect users to the appropriate mobile page .
Correct: “example.com/sport/” to “m.example.com/sport/” Wrong: “example.com/sport/” to “m.example.com”
Also, you need to make sure that if a page is 404 on desktop, it should be 404 on mobile as well.
If you don’t have a mobile version for a page, you can avoid redirecting to the mobile version and keep them on the desktop page.
3. How To Use Meta Refresh
A redirect can be done using a meta refresh tag like in the following example:
<meta http-equiv=”refresh” content=”0;url=http://example.com/new-page/” />
If you place this tag in /old-page/, it will immediately redirect the user to /new-page/.
Google does not prohibit this redirect, but does not recommend using it.
A meta refresh redirect should work. We don’t recommend it for 2 reasons: UX (keeps page in browser history, afaik) & processing time (we have to parse the page to see it). Once processed, it’s just like a redirect.
— 🍌 John 🍌 (@JohnMu) March 2, 2018
According to John Mueller, search engines may not be able to correctly recognize that type of redirect. The same goes for JavaScript redirects as well.
4. Avoid Redirect Chains
This message appears when you have an incorrect regular expression setting and end up in an infinite loop.
Screenshot by the author, December 2022
Usually, this happens when you have a redirect chain.
Let’s say you redirected page 1 to page 2 a long time ago. You may have forgotten that page 1 is redirected and decided to redirect page 2 to page 1 again.
As a result, you end up with a rule like this:
This will create an infinite loop and produce the error shown above.
Conclusion
Knowing what redirects are and what situation requires a specific status code is crucial to properly optimizing web pages. It is a key part of understanding SEO.
Many situations require precise knowledge of redirects, such as migrating a website to a new domain or creating a temporary hold page URL for a web page that will return under its regular URL.
While so much can be done with one plugin, plugins can be misused without properly understanding when and why to use a particular type of redirect.
Do redirects affect site speed?
Problems emerge when there are too many redirects in the page structure. Multiple redirects place a huge overhead on the website and can significantly slow it down.
Pourquoi 301 redirect ? A 301 redirect, or permanent redirect, is used to indicate that content on a page is no longer available and has been moved to another URL.
Comment do a redirection of the link ? The simplest redirect against another URL is to use HTML code with the http parameter equivalent to the actualizer. The content attribute defines the delay before the surfer redirects the user to the new web page.
Comment faire la redirection ?
For qu’an internet user you have to redirect to a URL, an HTTP request is made to the web server. This is the latter to deliver an HTTP status code specifying the redirect to be performed. The code de statut correspond to the name of redirections. The latter can be temporary or permanent.
Does the comment work with redirect? When you are on a web page that is redirected to another URL, your browser will receive a 301 or 302 message instead of receiving a 200 message since the URL to the page is redirected. Ensuite, your browser loads the web page sent in the HTTP 301 or 301 response.
Comment faire une redirection ?
Click on the URL Redirects website. Click on Ajouter une redirection d’URL dans l’angle supérieur droit. In the right pane, select the Standard or Flexible redirect type. A redirect standard is used to redirect one URL against another.
What is special about redirection? In this case, what are the particularities of the redirect? A redirect ensures qu’aucun Page Rank ne soit perdu. With a 301 redirect, web pages can be redirected from a protocol such as http to https.
Comment faire une redirection en php ?
To perform a redirect in PHP, use the header() function. This function sends HTTP entities to the server. Pour effectuer une redirection, il faut envoyer l’entête Location : suivi de l’URL de la nouvelle page. For this to work, it is recommended to use an absolute URL.
What is redirect() in PHP? Redirection from one page to another in PHP is commonly achieved using the following two ways: Using the Header function in PHP: The header() function is a built-in function in PHP which is used to send the HTTP header (Hyper Text Transfer Protocol) not processed to the customer.
What are the 4 types of redirects? Types of Redirects
- 301 Permanent.
- 302 Found.
- 307 Temporary.
Quelle est la différence entre les redirections 301 et 302 ?
They have been used by webmasters for several occasions in the life of an online site: refonte, change of the name of a site, migration and implementation of the https⦠protocol On parle de 301 pour un redirect permanent, as well as ‘on parle de 302 dans le cas d’une temporaire.
How do I fix a 302 redirect error?
What is a 302 Redirect? What is a 302 Redirect? While a 301 redirect is a permanent transfer of your URL, a 302 redirect is a temporary change that redirects both users and search engines to your new desired location for a limited time, until the redirect is removed.
Should a redirect be 301 or 302?
For permanent changes to a website and continued ranking through SEO, a 301 redirect is needed. On the other hand, if you’re only doing a temporary change, a 302 redirect is better. It tells the search engine that the changes are temporary and may not affect the original page’s SEO ranking.
What is the difference between 301 302 and 307 redirect? 302s are often used to create temporary redirects, but, with the advent of HTTP 1.1, 307 replaced it as a valid temporary redirect. While a 302 is a bit vague, a 307 specifically states that the requested URL has been moved to a temporary location and will return in some time.
What causes a 302 redirect?
What is an HTTP 302? The 302 status code is a redirect message that occurs when a resource or page you’re trying to load has been temporarily moved to a different location. It is usually caused by the web server and does not affect the user experience, as the redirection happens automatically.
What is a 302 redirect code? The 302 Found HyperText Transfer Protocol (HTTP) response code indicates that the requested resource has been temporarily moved to the URL provided by the Location header.
How does a 302 redirect work? A 302 redirect doesn’t pass the “juice” or keep your domain authority in the new location. It simply redirects the user to the new location for you so they don’t see a broken link, 404 page not found, or error page.
Does Google penalize for redirect?
Googlebot Cloaking/Redirects Showing different content/URLs to users and search engines (known as cloaking) or redirecting Googlebot and not users is a violation of Google’s Webmaster Guidelines and will result in a fine.
Does Google penalize 301 redirects? Search engines may see this as a game of the system and may penalize you for it. We’ve seen over time that 301 redirects don’t transfer all of the PageRank from one page to another, but they don’t take away any authority either.
Does redirection hurt SEO? Redirects are not bad for SEO, but – as with so many other things – only if you enter them correctly. A bad implementation could cause all kinds of problems, from loss of PageRank to loss of traffic. Redirecting pages is a must if you make any changes to your URLs.
Will 301 redirects hurt SEO?
This means that 301 redirects don’t hurt SEO performance or reduce the “PageRank” metrics associated with a page’s URL, although they aren’t crucial to search rankings either. All 300-level server-side redirects pass PageRank to the landing page (including 301, 302, and 307 redirects).
. 301 redirects may not improve the rankings of your web pages, but they can ensure that both Google and search users are directed to the content you want them to find. They also ensure that you don’t lose ranking signals created for old URLs when you move them to new ones.
Which is most effective SEO techniques?
Digital PR is one of the best SEO tactics to gain links from high authority websites on a large scale. Common digital PR strategies include: Writing press releases. Data-driven content creation (journalists love data)
What are the top 3 SEO strategies? So, to save you some time, I’m going to cover the five most impactful SEO strategies you should focus on when implementing SEO.
- Step 1: Search for keywords. …
- Step 2: Content Marketing. …
- Step 3: SEO on the page. …
- Step 4: Building Links. …
- Step 5: SEO outsourcing.
Which SEO technique is the most efficient in the long run? The best long-term SEO strategy is to align your website goals with the search engines goals. Search engines try to provide the best user experience. If your website provides the best keyword solution then your website will rank high.
Why are redirects used?
HTTP redirect code, redirect for short, is a way to forward visitors and search engines from one URL to another. Redirects are used when moving content to a new URL, when deleting pages, or when changing domain names or merging websites. Whenever possible, avoid using redirects.
Why are redirects important for SEO? Redirects solve this problem by seamlessly sending visitors to the new content location. Help search engines understand your site â Redirects tell search engines where content has been moved and whether the move is permanent or temporary. This affects whether and how pages appear in search results.
What is the purpose of the redirects? What is a redirect? A redirect is a way of sending both 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.