Redirects for SEO needs to be used properly because they impact how websites are crawled and indexed by Google.
While many people think about redirects as a web detour sign, much more is happening, and it’s remarkably satisfying to find.
Keep checking out for a comprehensive summary of redirects and the correct application for technical SEO.
What Is A Redirect?
Site redirects tell browsers and search engines info about a URL and where to discover the website.
A URL redirect involves code executed to a specific URL, or a group of URLs so that the user (or search engine) is sent out to a various page to the real URL that was input or clicked.
A redirect can be set as a:
- Temporary redirect: 302, 303, 307, 308.
- Long-term redirect: 301.
When To Utilize Redirects
The main factors to utilize redirects are:
- A private page or entire domain has actually been moved (URL altered).
- To allow the usage of URL shorteners or ‘pretty URLs.’
- Site migration (e.g., HTTP to HTTPS).
For SEO purposes, URL redirects are important since they:
- Forward authority of any links pointing to a page that has moved or been deleted.
- Prevent 404 page not discovered mistakes (although in some cases it is much better to leave a 404).
Redirects can be executed on a group or domain-wide basis however often require to be set on an individual basis to prevent problems.
When utilizing RegEX for group redirects, it can have unanticipated outcomes if your logic isn’t perfect!
Types Of Redirects
There are 3 main types of redirects:
- Meta Refresh redirects are set at the page level however are typically not recommended for SEO purposes. There are two types of meta redirect: postponed which is viewed as a short-lived redirect, and instant, which is viewed as an irreversible redirect.
- HTTP redirects are set server-side and the very best approach for SEO purposes– we covered thorough below.
What Is A HTTP Reaction Status Code?
Browsers and search engine crawlers like GoogleBot are called user representatives.
When a user representative attempts to access a webpage, what occurs is that the user representative makes a request, and the website server problems a reaction.
The action is called an HTTP response status code. It supplies a status for the request for a URL.
In the circumstance where a user representative like GoogleBot demands a URL, the server offers an action.
For instance, if the request for a URL achieves success, the server will supply a reaction code of 200, which implies the ask for a URL was successful.
So, when you think of a GoogleBot reaching a website and trying to crawl it, what’s taking place is a series of demands and reactions.
An HTTP redirect is a server action to ask for a URL.
If the URL exists at a different URL (since it was moved), the server informs the user agent that the URL request is being redirected to a different URL.
The reaction code for an altered URL is normally in the type of a 301 or 302 action status code.
The whole 3xx series of action codes interact much info that can optionally be acted upon by the user representative.
An example of an action that the user agent can take is to conserve a cache of the new URL so that the next time the old URL is asked for, it will ask for the brand-new URL rather.
So, a 301 and a 302 redirect is more than an internet roadway indication that says, “Go here, not there.”
3XX Series Of Status Codes
Redirects are more than simply the two status codes everyone recognizes with, the 301 and 302 action codes.
There are a total of 7 official 3xx response status codes.
These are the various sort of redirects readily available for use:
- 300 Multiple Choices.
- 301 Moved Permanently.
- 302 Found.
- 303 See Other.
- 304 Not Customized.
- 305 Use Proxy.
- 306 (Unused).
- 307 Momentary Redirect.
- 308 Permanent Redirect.
A few of the above status codes have actually not been around as long and might not be utilized. So, before using any redirect code besides 301 or 302, make sure that the desired user agent can interpret it.
Since GoogleBot utilizes the latest version of Chrome (called a headless internet browser), it’s easy to inspect if a status code works by checking if Chrome acknowledges the status code with a browser compatibility list.
For SEO, one ought to stay with utilizing the 301 and 302 action codes unless there is a specific factor to use one of the other codes.
301: Moved Permanently
The 301 status code is regularly referenced as the 301 redirects. But the official name is 301 Moved Permanently.
The 301 redirect suggests to a user agent that the URL (in some cases described as a target resource or just resource) was altered to another area and that it ought to utilize the brand-new URL for future requests.
As discussed earlier, there is more details as well.
The 301 status code likewise recommends to the user representative:
- Future requests for the URL must be made with the brand-new URL.
- Whoever is making the demand needs to update their links to the brand-new URL.
- Subsequent requests can be altered from GET to POST.
That last point is a technical problem. According to the main standards for the 301 status code:
“Keep in mind: For historic factors, a user representative MAY alter the demand technique from POST to GET for the subsequent request. If this habits is undesired, the 308 (Permanent Redirect) status code can be used rather.”
For SEO, when search engines see a 301 redirect, they pass the old page’s ranking to the brand-new one.
Before making a change, you should be careful when using a 301 redirect. The 301 redirects should only be utilized when the change to a brand-new URL is long-term.
The 301 status code must not be used when the change is momentary.
Furthermore, if you change your mind later and return to the old URL, the old URL might not rank anymore and might require time to restore the rankings.
So, the main thing to bear in mind is that a 301 status code will be utilized when the change is long-term.
The main point to understand about the 302 status code is that it’s useful for circumstances where a URL is briefly altered.
The significance of this response code is that the URL is temporarily at a various URL, and it is suggested to utilize the old URL for future demands.
The 302 redirect status code likewise features a technical caveat associated to GET and Post:
“Note: For historical reasons, a user representative MAY change the demand method from POST to GET for the subsequent demand. If this behavior is undesirable, the 307 (Short-lived Redirect) status code can be utilized rather.”
The recommendation to “historical reasons” might refer to old or buggy user representatives that may alter the request approach.
307: Temporary Redirect
A 307 redirect means the asked for URL is temporarily moved, and the user agent must use the initial URL for future demands.
The only distinction between a 302 and a 307 status code is that a user agent need to request the brand-new URL with the same HTTP request used to request the initial URL.
That implies if the user agent requests the page with a GET demand, then the user agent need to utilize a GET ask for the brand-new short-term URL and can not utilize the POST request.
The Mozilla documents of the 307 status code explains it more clearly than the official documents.
“The server sends this response to direct the customer to get the asked for resource at another URI with very same technique that was utilized in the previous request.
This has the very same semantics as the 302 Found HTTP reaction code, with the exception that the user representative need to not change the HTTP approach utilized: if a POST was used in the very first demand, a POST must be utilized in the second request.”
Aside from the 307 status code requiring subsequent requests to be of the exact same kind (POST or GET) which the 302 can go in either case, whatever else is the exact same between the 302 and the 307 status codes.
302 Vs. 307
You might handle a redirect through server config files.htaccess on Apache, example.conf file on Nginx or via plugins if you are utilizing WordPress.
In all instances, they have the exact same syntax for writing redirect rules. They differ only with commands utilized in configuration files. For example, a redirect on Apache will appear like this:
Choices +FollowSymlinks RewriteEngine on RedirectMatch 301 ^/ oldfolder// newfolder/
(You can read about symlinks here.)
On Nginx servers, it will appear like this:
reword ^/ oldfolder// newfolder/ long-term;
The commands utilized to inform the server’s status code of redirect and the action command vary.
- Servers status code of redirect: “301 ″ vs. “long-term.”
- Action command: “RedirectMatch” vs. “reword.”
However the redirect syntax (^/ oldfolder// newfolder/) is the same for both.
On Apache, ensure that mod_rewrite and mod_alias modules (responsible for dealing with redirects) are made it possible for on your server.
Considering that the most commonly spread out server type is Apache, here are examples for.htaccess apache files.
Ensure that the.htaccess file has these two lines above the redirect guidelines and put the rules listed below them:
Alternatives +FollowSymlinks RewriteEngine on
Read the official paperwork to read more about the RewriteEngine.
To comprehend the examples below, you may describe the table below on RegExp essentials.
|*||absolutely no or more times|
|.||any single character|
|?||Absolutely no or one time|
|^||Start of the string|
|$||End of the string|
|| b||OR operadn” |” a or b|
|(z)||remembers the match to be used when calling $1|
How To Produce Redirects
How To Create A Redirect For A Single URL
The most typical and commonly utilized type of redirect is when deleting pages or changing URLs.
For instance, say you altered the URL from/ old-page/ to/ new-page/. The redirect rule would be:
RewriteRule ^ old-page(/? |/. *)$/ new-page/ [R=301, L] Or RedirectMatch 301 ^/ old-page(/? |/. *)$/ new-page/
The only difference in between the two techniques is that the first utilizes the Apache mod_rewrite module, and the 2nd uses mod_alias. It can be done utilizing both approaches.
The routine expression “^” implies the URL must begin with “/ old-page” while (/? |/. *)$ indicates that anything that follows “/ old-page/” with a slash “/” or without a precise match should be redirected to/ new-page/.
We could also utilize (. *), i.e., ^/ old-page(. *), however the problem is, if you have another page with a comparable URL like/ old-page-other/, it will also be redirected when we only want to redirect/ old-page/.
The following URLs will match and be directed to a new page:
|/ old-page/||/ new-page/|
|/ old-page||/ new-page/|
|/ old-page/? utm_source=facebook.com||/ new-page/? utm_source=facebook.com|
|/ old-page/child-page/||/ new-page/|
It will reroute any variation of the page URL to a new one. If we use redirect in the list below form:
Redirect 301/ old-page// new-page/
Without routine expressions, all URLs with UTM question string, e.g.,/ old-page? utm_source=facebook.com (which is common considering that URLs are utilized to be shared over a social media), would end up as 404s.
Even/ old-page without a routing slash “/” would wind up as a 404.
Redirect All Other than
Let’s state we have a lot of URLs like/ category/old-subcategory -1/,/ category/old-subcategory -2/,/ category/final-subcategory/ and wish to combine all subcategories into/ category/final-subcategory/. We require the “all except” rule here.
Otherwise, if we have some properties like “/ category/image. jpg,” it will likewise be rerouted to “/ final-subcategory/” and cause an image break.
Directory site Change
You can utilize the guideline below if you did a classification restructuring and want to move whatever from the old directory to the brand-new one.
RewriteRule ^ old-directory$/ new-directory/ [R=301, NC, L] RewriteRule ^ old-directory/(. *)$/ new-directory/$1 [R=301, NC, L] I utilized $1 in the target to inform the server that it need to remember everything in the URL that follows/ old-directory/ (i.e.,/ old-directory/subdirectory/) and pass it (i.e., “/ subdirectory/”) onto the destination. As a result, it will be redirected to/ new-directory/subdirectory/.
I used 2 guidelines: one case without any tracking slash at the end and the other one with a routing slash.
I could integrate them into one rule utilizing (/? |. *)$ RegExp at the end, however it would cause issues and include a “//” slash to the end of the URL when the asked for URL without any routing slash has a question string (i.e., “/ 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 want to remove them.
For the URL http://yourwebiste.com/example-chicago-event/, the redirect guideline would be:
RewriteRule ^(. *)-chicago-(. *) http://% SERVER_NAME/$1-$2 [NC, R=301, L] If the example URL is in the form http://yourwebiste.com/example/chicago/event/, then the redirect would be: RewriteRule ^(. *)/ chicago/(. *) http://% /$1/$2 [NC, R=301, L] Set A Canonical URL
Having canonical URLs is the most important part of SEO.
If missing out on, you may endanger your website with duplicate content issues because search engines treat URLs with “www” and “non-www” versions as different pages with the very same content.
For that reason, you need to ensure you run the site just with one version you select.
If you want to run your website with the “www” version, use this guideline:
RewriteCond % ^ yourwebsite.com [NC] RewriteRule ^(. *)$ http://www.yourwebsite.com/$1 [L, R=301] For a “non-www” variation: RewriteCond % HTTP_HOST ^ www.yourwebsite.com [NC] RewriteRule ^(. *)$ http://yourwebsite.com/$1 [L, R=301] Tracking slash is likewise part of canonicalization because URLs with a slash at the end or without are likewise treated in a different way. RewriteCond % !-f RewriteRule ^(. * [^/]$/$1/ [L, R=301] This will make certain the/ example-page is redirected to/ example-page/. You might pick to eliminate the slash rather of including then you will require the other guideline listed below: RewriteCond % REQUEST_FILENAME!-d RewriteRule ^(. *)/$/$1 [L, R=301]HTTP To HTTPS Redirect
After Google’s effort to motivate site owners to use SSL, migrating to HTTPS is one of the typically utilized redirects that almost every site has.
The rewrite rule below can be used to require HTTPS on every website.
RewriteCond % ^ yourwebsite.com [NC, OR] RewriteCond % HTTP_HOST ^ www.yourwebsite.com [NC] RewriteRule ^(. *)$ https://www.yourwebsite.com/$1 [L, R=301, NC] Using this, you can integrate a www or non-www version redirect into one HTTPS redirect guideline.
Redirect From Old Domain To New
This is also among the most secondhand redirects when you decide to rebrand and require to alter your domain. The rule listed below redirects old-domain. com to new-domain. com.
RewriteCond % ^ old-domain. com$ [OR] RewriteCond % HTTP_HOST ^ www.old-domain.com$ RewriteRule (. *)$ http://www.new-domain.com/$1 [R=301, L] It uses two cases: one with the “www” version of URLs and another “non-www” due to the fact that any page for historic reasons may have incoming links to both variations.
A lot of site owners use WordPress and might not require a.htaccess apply for redirects however utilize a plugin rather.
Handling redirects utilizing plugins may be slightly different from what we talked about above. You may require to read their documents to manage RegExp correctly for the specific plugin.
From the existing ones, I would suggest a free plugin called Redirection, which has numerous criteria to control redirect guidelines and numerous helpful docs.
Reroute Best Practices
1. Do not Redirect All 404 Broken URLs To The Homepage
This case frequently takes place when you are too lazy to investigate your 404 URLs and map them to the appropriate landing page.
According to Google, they are still all treated as 404s.
Yeah, it’s not a fantastic practice (confuses users), and we mainly treat them as 404s anyway (they’re soft-404s), so there’s no advantage. It’s not seriously broken/bad, but additional intricacy for no good reason– make a much better 404 page instead.
— John (@JohnMu) January 8, 2019
If you have too many pages like this, you must consider developing gorgeous 404 pages and engaging users to browse additional or find something besides what they were looking for by displaying a search alternative.
It is strongly suggested by Google that redirected page content must be comparable to the old page. Otherwise, such a redirect might be considered a soft 404, and you will lose the rank of that page.
2. Get Mobile Page-Specific Redirects Right
If you have different URLs for desktop and mobile websites (i.e., “example.com” for desktop and “m.example.com” for mobile), you should ensure to redirect users to the appropriate page of the mobile variation.
Correct: “example.com/sport/” to “m.example.com/sport/”
Wrong: “example.com/sport/” to “m.example.com”
Also, you have to guarantee that if one page is 404 on the desktop, it ought to also be 404 on mobile.
If you have no mobile version for a page, you can avoid redirecting to the mobile variation and keep them on the desktop page.
3. How To Use Meta Refresh
It is possible to do a redirect using a meta revitalize tag like the example listed below:
If you insert this tag in/ old-page/, it will redirect the user immediately to/ new-page/.
Google does not prohibit this redirect, however it doesn’t recommend utilizing it.
A meta refresh type redirect must simply work. We do not advise it for 2 factors: UX (it keeps the page in internet browser history, afaik) & processing time (we need to parse the page to see it). As soon as processed, it’s similar to a redirect.
— John (@JohnMu) March 2, 2018
4. Prevent Redirect Chains
This message displays when you have a wrong routine expression setup and ends up in a boundless loop.
Screenshot by author, December 2022 Normally, this takes place when you have a redirect chain. Let’s state you rerouted page 1 to page 2 a long period of time back. You might have forgotten that
page 1 is redirected and decided to redirect page 2 to page 1 once again. As an outcome, you will end up with a guideline like this: RewriteRule ^ page1/ page2 [R
=301, NC, L] RewriteRule ^ page2/ page1 [R=301, NC, L] This will create a limitless loop and produce the error shown above. Conclusion Knowing what
redirects are and which circumstance needs a specific status code is essential to
webpages appropriately. It’s a core part of understanding SEO. Numerous circumstances require exact knowledge of redirects, such as migrating a website to a brand-new domain or producing a short-term holding page URL for a website that will return under its typical URL. While so much is possible with a plugin, plugins can be misused without properly understanding when and why to use a particular
sort of redirect. More Resources: Included Image: