URL Redirects For SEO: A Technical Guide

Posted by

Redirects for SEO ought to be used properly due to the fact that they affect how websites are crawled and indexed by Google.

While the majority of people think about redirects as an internet detour indication, far more is taking place, and it’s remarkably satisfying to find.

Keep reading for a thorough summary of redirects and the proper application for technical SEO.

What Is A Redirect?

Site reroutes inform browsers and search engines information about a URL and where to discover the web page.

A URL redirect includes code carried out to a specific URL, or a group of URLs so that the user (or search engine) is sent to a different page to the actual URL that was input or clicked.

A redirect can be set as a:

  • Temporary redirect: 302, 303, 307, 308.
  • Irreversible redirect: 301.

When To Use Redirects

The primary factors to use redirects are:

  • An individual page or whole domain has been moved (URL altered).
  • To permit the use of URL shorteners or ‘quite URLs.’
  • Site migration (e.g., HTTP to HTTPS).

For SEO purposes, URL redirects are essential due to the fact that they:

  • Forward authority of any links indicating a page that has actually moved or been deleted.
  • Avoid 404 page not found mistakes (although in some cases it is much better to leave a 404).

Redirects can be carried out on a group or domain-wide basis however frequently require to be set on an individual basis to prevent issues.

When utilizing RegEX for group reroutes, it can have unforeseen results if your reasoning isn’t perfect!

Types Of Redirects

There are three main types of redirects:

  • Meta Refresh redirects are set at the page level but are typically not recommended for SEO functions. There are two kinds of meta redirect: postponed which is seen as a temporary redirect, and immediate, which is seen as a long-term redirect.
  • Javascript redirects are likewise set on the client side’s page and can cause SEO problems. Google has specified a choice for HTTP server-side reroutes.
  • HTTP redirects are set server-side and the very best technique for SEO functions– we covered thorough listed below.

What Is A HTTP Reaction Status Code?

Web browsers and online search engine spiders like GoogleBot are called user agents.

When a user representative attempts to access a web page, what occurs is that the user representative makes a request, and the site server concerns an action.

The response is called an HTTP response status code. It provides a status for the request for a URL.

In the situation where a user representative like GoogleBot demands a URL, the server gives a reaction.

For example, if the ask for a URL is successful, the server will offer a reaction code of 200, which means the request for a URL was successful.

So, when you think about a GoogleBot reaching a site and trying to crawl it, what’s taking place is a series of demands and actions.

HTTP Redirects

An HTTP redirect is a server reaction to ask for a URL.

If the URL exists at a various URL (because it was moved), the server tells the user representative that the URL request is being redirected to a different URL.

The action code for a changed URL is generally in the form of a 301 or 302 reaction status code.

The whole 3xx series of response codes communicate much information that can additionally be acted on by the user representative.

An example of an action that 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 ask for the brand-new URL rather.

So, a 301 and a 302 redirect is more than a web roadway sign that says, “Go here, not there.”

3XX Series Of Status Codes

Redirects are more than just the 2 status codes everyone is familiar with, the 301 and 302 reaction codes.

There are an overall of seven main 3xx reaction status codes.

These are the different kinds of redirects readily available for use:

  • 300 Multiple Choices.
  • 301 Moved Permanently.
  • 302 Found.
  • 303 See Other.
  • 304 Not Modified.
  • 305 Usage Proxy.
  • 306 (Unused).
  • 307 Temporary Redirect.
  • 308 Irreversible Redirect.

Some of the above status codes have actually not been around as long and might not be utilized. So, before using any redirect code aside from 301 or 302, make certain that the desired user agent can analyze it.

Because GoogleBot utilizes the current version of Chrome (called a headless web browser), it’s easy to examine if a status code is compatible by examining if Chrome recognizes the status code with a browser compatibility list.

For SEO, one should stick to utilizing the 301 and 302 action codes unless there is a specific reason to use one of the other codes.

301: Moved Permanently

The 301 status code is regularly referenced as the 301 redirects. However the official name is 301 Moved Completely.

The 301 redirect suggests to a user agent that the URL (in some cases referred to as a target resource or just resource) was altered to another area which it must utilize the brand-new URL for future demands.

As discussed previously, there is more details too.

The 301 status code also recommends to the user representative:

  • Future ask for the URL must be made with the 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 requirements for the 301 status code:

“Keep in mind: For historical factors, a user agent MAY alter the request technique from POST to GET for the subsequent demand. If this behavior is undesired, the 308 (Long-term Redirect) status code can be utilized rather.”

For SEO, when online search engine see a 301 redirect, they pass the old page’s ranking to the new one.

Before making a modification, you must beware when utilizing a 301 redirect. The 301 redirects must only be used when the change to a new URL is permanent.

The 301 status code should not be utilized when the change is short-lived.

Additionally, if you change your mind later and go back to the old URL, the old URL might not rank anymore and may take some time to restore the rankings.

So, the main thing to remember is that a 301 status code will be used when the modification is irreversible.

302: Found

The main point to understand about the 302 status code is that it works for scenarios where a URL is temporarily changed.

The meaning of this response code is that the URL is momentarily at a various URL, and it is suggested to use the old URL for future demands.

The 302 redirect status code also comes with a technical caveat related to GET and Post:

“Note: For historic factors, a user representative MAY change the demand method from POST to GET for the subsequent demand. If this behavior is undesired, the 307 (Short-lived Redirect) status code can be used rather.”

The reference to “historic factors” may refer to old or buggy user agents that may alter the demand method.

307: Temporary Redirect

A 307 redirect means the asked for URL is temporarily moved, and the user agent should utilize the initial URL for future demands.

The only difference in between a 302 and a 307 status code is that a user agent need to ask for the new URL with the exact same HTTP request utilized to ask for the initial URL.

That suggests if the user agent demands the page with a GET demand, then the user agent need to use a GET request for the new momentary 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 requested resource at another URI with very same method that was utilized in the previous request.

This has the exact same semantics as the 302 Found HTTP action code, with the exception that the user agent should not alter the HTTP approach utilized: if a POST was used in the very first request, a POST must be utilized in the second request.”

Other than the 307 status code requiring subsequent demands to be of the very same kind (POST or GET) and that the 302 can go either way, whatever else is the very same in between the 302 and the 307 status codes.

302 Vs. 307

You may deal with a redirect by means of server config files.htaccess on Apache, example.conf file on Nginx or by means of plugins if you are utilizing WordPress.

In all instances, they have the very same syntax for writing redirect guidelines. They differ just with commands utilized in configuration files. For example, a redirect on Apache will appear like this:

Options +FollowSymlinks RewriteEngine on RedirectMatch 301 ^/ oldfolder// newfolder/

(You can read about symlinks here.)

On Nginx servers, it will look like this:

reword ^/ oldfolder// newfolder/ permanent;

The commands utilized to tell the server’s status code of redirect and the action command vary.

For example:

  • Servers status code of redirect: “301 ″ vs. “long-term.”
  • Action command: “RedirectMatch” vs. “rewrite.”

But the redirect syntax (^/ oldfolder// newfolder/) is the exact same for both.

On Apache, ensure that mod_rewrite and mod_alias modules (responsible for handling redirects) are made it possible for on your server.

Because 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 rules and put the rules listed below them:

Choices +FollowSymlinks RewriteEngine on

Read the main paperwork to get more information about the RewriteEngine.

To understand the examples listed below, you might describe the table listed below on RegExp essentials.

* absolutely no or more times
+ One 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 common and widely used type of redirect is when deleting pages or changing URLs.

For instance, say you changed 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 between the two techniques is that the very first utilizes the Apache mod_rewrite module, and the 2nd uses mod_alias. It can be done using both techniques.

The routine expression “^” suggests the URL must begin with “/ old-page” while (/? |/. *)$ suggests that anything that follows “/ old-page/” with a slash “/” or without an exact match should be rerouted to/ new-page/.

We could likewise use (. *), i.e., ^/ old-page(. *), but the issue is, if you have another page with a comparable URL like/ old-page-other/, it will also be redirected when we only wish to redirect/ old-page/.

The following URLs will match and be directed to a brand-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 brand-new one. If we utilize reroute in the following 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 prevails since URLs are utilized to be shared over a social network), would wind up as 404s.

Even/ old-page without a tracking slash “/” would wind up as a 404.

Redirect All Except

Let’s state we have a lot of URLs like/ category/old-subcategory -1/,/ category/old-subcategory -2/,/ category/final-subcategory/ and want to combine all subcategories into/ category/final-subcategory/. We require the “all except” guideline here.

RewriteCond % !/ category/final-subcategory/ RewriteCond % !-f RewriteRule ^(classification/)./ category/final-subcategory/ [R=301, L] Here, we want to redirect all under/ category/ on the third line other than if it is/ category/final-subcategory/ on the 4th line. We likewise have the “!-f” rule on the second line, neglecting any file like images, CSS, or JavaScript files.

Otherwise, if we have some possessions like “/ category/image. jpg,” it will also be rerouted to “/ final-subcategory/” and cause an image break.

Directory site Change

You can utilize the rule listed below if you did a classification restructuring and want to move whatever from the old directory site to the 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 should remember whatever in the URL that follows/ old-directory/ (i.e.,/ old-directory/subdirectory/) and pass it (i.e., “/ subdirectory/”) onto the location. As a result, it will be redirected to/ new-directory/subdirectory/.

I used two rules: one case with no trailing slash at the end and the other one with a trailing slash.

I could combine them into one rule using (/? |. *)$ RegExp at the end, but it would cause issues and include a “//” slash to the end of the URL when the asked for URL with no trailing 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 site with the city name “Chicago” and wish to eliminate them.

For the URL http://yourwebiste.com/example-chicago-event/, the redirect rule would be:

RewriteRule ^(. *)-chicago-(. *) http://% /$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 threaten your site with duplicate content problems due to the fact that online search engine treat URLs with “www” and “non-www” variations as different pages with the same content.

For that reason, you should ensure you run the website only with one variation you select.

If you wish to run your website with the “www” variation, use this rule:

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] Routing slash is likewise part of canonicalization given that URLs with a slash at the end or without are also treated in a different way. RewriteCond % REQUEST_FILENAME!-f RewriteRule ^(. * [^/]$/$1/ [L, R=301] This will ensure the/ example-page is rerouted to/ example-page/. You may pick to remove the slash instead of adding then you will need the other guideline below: RewriteCond % !-d RewriteRule ^(. *)/$/$1 [L, R=301]HTTP To HTTPS Redirect

After Google’s initiative to motivate website owners to utilize SSL, migrating to HTTPS is among the frequently used redirects that practically every site has.

The rewrite rule listed below can be utilized to force HTTPS on every site.

RewriteCond % ^ yourwebsite.com [NC, OR] RewriteCond % ^ 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 rule.

Redirect From Old Domain To New

This is also among the most used redirects when you choose to rebrand and need to change your domain. The guideline listed below reroutes old-domain. com to new-domain. com.

RewriteCond % HTTP_HOST ^ 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” variation of URLs and another “non-www” due to the fact that any page for historic reasons may have inbound links to both versions.

Most website owners utilize WordPress and might not require a.htaccess file for redirects but utilize a plugin instead.

Dealing with redirects utilizing plugins may be slightly different from what we talked about above. You may need to read their documentation to deal with RegExp correctly for the specific plugin.

From the existing ones, I would advise a totally free plugin called Redirection, which has lots of parameters to manage redirect rules and numerous beneficial docs.

Reroute Finest Practices

1. Do not Redirect All 404 Broken URLs To The Homepage

This case often 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.

If you have a lot of pages like this, you should think about developing stunning 404 pages and engaging users to browse more or discover something aside from what they were trying to find by displaying a search alternative.

It is strongly advised by Google that rerouted page material need to be equivalent to the old page. Otherwise, such a redirect may be considered a soft 404, and you will lose the rank of that page.

2. Get Mobile Page-Specific Reroutes Right

If you have various URLs for desktop and mobile sites (i.e., “example.com” for desktop and “m.example.com” for mobile), you should ensure to reroute users to the appropriate page of the mobile variation.

Correct: “example.com/sport/” to “m.example.com/sport/”
Incorrect: “example.com/sport/” to “m.example.com”

Likewise, you need to guarantee that if one page is 404 on the desktop, it should also be 404 on mobile.

If you have no mobile version for a page, you can prevent rerouting to the mobile version and keep them on the desktop page.

3. How To Utilize Meta Refresh

It is possible to do a redirect using a meta revitalize tag like the example below:

If you place this tag in/ old-page/, it will redirect the user immediately to/ new-page/.

Google does not prohibit this redirect, but it doesn’t advise using it.

According to John Mueller, search engines might not have the ability to acknowledge that type of redirect effectively. The same is also true about JavaScript redirects.

4. Prevent Redirect Chains

This message displays when you have an incorrect routine expression setup and winds up in a limitless loop.

Screenshot by author, December 2022 Typically, this happens when you have a redirect chain. Let’s say you redirected 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 again. As a result, you will wind up with a rule like this: RewriteRule ^ page1/ page2 [R

=301, NC, L] RewriteRule ^ page2/ page1 [R=301, NC, L] This will create an infinite loop and produce the error shown above. Conclusion Knowing what

redirects are and which scenario needs a specific status code is basic to

enhancing

webpages correctly. It’s a core part of understanding SEO. Lots of scenarios need accurate knowledge of redirects, such as migrating a site to a new domain or developing a short-term holding page URL for a webpage that will return under its normal URL. While a lot is possible with a plugin, plugins can be misused without properly comprehending when and why to utilize a specific

sort of redirect. More Resources: Included Image: