URL Redirects For SEO: A Technical Guide

Posted by

Reroutes for SEO should be used correctly due to the fact that they impact how sites are crawled and indexed by Google.

While the majority of people think of redirects as an internet detour sign, far more is taking place, and it’s remarkably pleasurable to discover.

Keep checking out for an extensive introduction of redirects and the correct application for technical SEO.

What Is A Redirect?

Website redirects inform browsers and online search engine info about a URL and where to discover the web page.

A URL redirect involves code implemented to a specific URL, or a group of URLs so that the user (or search engine) is sent to a various page to the real URL that was input or clicked.

A redirect can be set as a:

  • Momentary redirect: 302, 303, 307, 308.
  • Permanent redirect: 301.

When To Use Redirects

The main reasons to utilize redirects are:

  • A private page or whole domain has been moved (URL altered).
  • To permit the use of URL shorteners or ‘pretty URLs.’
  • Website migration (e.g., HTTP to HTTPS).

For SEO functions, URL redirects are important because they:

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

Redirects can be implemented on a group or domain-wide basis however often need to be set on a private basis to prevent problems.

When utilizing RegEX for group redirects, it can have unanticipated outcomes if your reasoning isn’t perfect!

Types Of Redirects

There are 3 primary kinds of redirects:

  • Meta Refresh redirects are set at the page level but are generally not recommended for SEO functions. There are two kinds of meta redirect: postponed which is seen as a momentary redirect, and instant, which is viewed as a long-term redirect.
  • Javascript reroutes are also set on the customer side’s page and can cause SEO problems. Google has actually stated a choice for HTTP server-side reroutes.
  • HTTP redirects are set server-side and the best approach for SEO purposes– we covered thorough listed below.

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 website, what occurs is that the user agent makes a request, and the site server problems a response.

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

In the circumstance where a user agent like GoogleBot demands a URL, the server offers a response.

For instance, if the request for a URL is successful, the server will provide an action code of 200, which implies the ask for a URL succeeded.

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

HTTP Reroutes

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 informs the user representative that the URL demand is being rerouted to a various URL.

The response code for an altered URL is typically in the type of a 301 or 302 action status code.

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

An example of an action that the user agent can take is to save a cache of the brand-new URL so that the next time the old URL is asked for, it will ask for the brand-new URL instead.

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 everybody is familiar with, the 301 and 302 reaction codes.

There are an overall of seven official 3xx action status codes.

These are the different type of redirects available for use:

  • 300 Numerous Options.
  • 301 Moved Completely.
  • 302 Found.
  • 303 See Other.
  • 304 Not Customized.
  • 305 Use Proxy.
  • 306 (Unused).
  • 307 Short-term Redirect.
  • 308 Irreversible Redirect.

Some of the above status codes have actually not been around as long and may not be utilized. So, before utilizing any redirect code besides 301 or 302, be sure that the intended user agent can interpret it.

Because GoogleBot uses the most recent variation of Chrome (called a headless browser), it’s simple to examine if a status code is compatible by checking if Chrome acknowledges the status code with an internet browser compatibility list.

For SEO, one must stay with utilizing the 301 and 302 action codes unless there is a specific factor to utilize among the other codes.

301: Moved Permanently

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

The 301 redirect indicates to a user representative that the URL (often described as a target resource or simply resource) was altered to another location and that it should use the brand-new URL for future demands.

As pointed out previously, there is more information also.

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 request ought to update their links to the brand-new URL.
  • Subsequent demands can be changed from GET to POST.

That last point is a technical issue. According to the main requirements for the 301 status code:

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

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

Prior to making a modification, you should take care when using a 301 redirect. The 301 redirects need to just be utilized when the modification to a brand-new URL is irreversible.

The 301 status code must not be used when the modification is momentary.

In addition, if you change your mind later and return to the old URL, the old URL may not rank any longer and might require time to restore the rankings.

So, the main point to keep in mind is that a 301 status code will be utilized when the modification is permanent.

302: Found

The main point to comprehend about the 302 status code is that it’s useful for situations where a URL is briefly altered.

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

The 302 redirect status code likewise comes with a technical caution related to GET and Post:

“Note: For historic reasons, a user representative MAY alter the demand method from POST to GET for the subsequent demand. If this habits is undesirable, the 307 (Momentary Redirect) status code can be used rather.”

The recommendation to “historical factors” may refer to old or buggy user representatives that may change the demand method.

307: Temporary Redirect

A 307 redirect suggests the asked for URL is momentarily moved, and the user agent must use the original URL for future requests.

The only distinction in between a 302 and a 307 status code is that a user agent should ask for the brand-new URL with the exact same HTTP request used to ask for the original URL.

That implies if the user representative demands the page with a GET request, then the user representative need to utilize a GET ask for the new short-term URL and can not use the POST request.

The Mozilla documents of the 307 status code describes it more clearly than the official paperwork.

“The server sends this action to direct the client to get the requested resource at another URI with exact same method that was utilized in the previous demand.

This has the same semantics as the 302 Found HTTP action code, with the exception that the user representative need to not change the HTTP technique used: if a POST was used in the very first request, a POST should be used in the 2nd request.”

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

302 Vs. 307

You might handle a redirect via server config files.htaccess on Apache, example.conf file on Nginx or through plugins if you are utilizing WordPress.

In all instances, they have the exact same syntax for writing redirect guidelines. They vary only 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:

rewrite ^/ oldfolder// newfolder/ long-term;

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. “permanent.”
  • Action command: “RedirectMatch” vs. “reword.”

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

On Apache, guarantee that mod_rewrite and mod_alias modules (responsible for handling redirects) are allowed on your server.

Because the most widely spread out server type is Apache, here are examples for.htaccess apache files.

Make certain that the.htaccess file has these two lines above the redirect guidelines and put the guidelines below them:

Options +FollowSymlinks RewriteEngine on

Read the main documents to read more about the RewriteEngine.

To comprehend the examples below, you may refer to the table listed below on RegExp essentials.

* zero or more times
+ One or more times
. any single character
? No or one time
^ Start of the string
$ End of the string
| b OR operadn” |” a or b
(z) remembers the match to be utilized when calling $1

How To Produce Redirects

How To Develop A Redirect For A Single URL

The most common and commonly used type of redirect is when erasing pages or changing URLs.

For example, say you altered the URL from/ old-page/ to/ new-page/. The redirect guideline would be:

RewriteRule ^ old-page(/? |/. *)$/ new-page/ [R=301, L] Or RedirectMatch 301 ^/ old-page(/? |/. *)$/ new-page/

The only difference between the 2 approaches is that the very first utilizes the Apache mod_rewrite module, and the second uses mod_alias. It can be done using both approaches.

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

We might likewise utilize (. *), i.e., ^/ old-page(. *), but the problem is, if you have another page with a comparable URL like/ old-page-other/, it will likewise be rerouted when we just want to reroute/ 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 new one. If we use reroute in the following type:

Redirect 301/ old-page// new-page/

Without regular expressions, all URLs with UTM inquiry string, e.g.,/ old-page? utm_source=facebook.com (which prevails since URLs are used to be shared over a social network), would end 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” rule here.

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

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

Directory site Change

You can use the guideline below if you did a category restructuring and wish to move whatever from the old directory site 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 used $1 in the target to tell the server that it should keep in mind whatever in the URL that follows/ old-directory/ (i.e.,/ old-directory/subdirectory/) and pass it (i.e., “/ subdirectory/”) onto the destination. As an outcome, it will be rerouted to/ new-directory/subdirectory/.

I used two guidelines: one case without any trailing slash at the end and the other one with a routing slash.

I could combine them into one rule using (/? |. *)$ RegExp at the end, however it would trigger problems and add a “//” slash to the end of the URL when the requested URL without any tracking slash has a question string (i.e., “/ old-directory? utm_source=facebook” would be rerouted 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 wish to eliminate them.

For the URL http://yourwebiste.com/example-chicago-event/, the redirect rule 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 fundamental part of SEO.

If missing out on, you may endanger your site with duplicate content problems since online search engine treat URLs with “www” and “non-www” versions as various pages with the same content.

For that reason, you need to guarantee you run the website only with one variation you pick.

If you want to run your site with the “www” version, utilize this guideline:

RewriteCond % ^ yourwebsite.com [NC] RewriteRule ^(. *)$ http://www.yourwebsite.com/$1 [L, R=301] For a “non-www” variation: RewriteCond % ^ www.yourwebsite.com [NC] RewriteRule ^(. *)$ http://yourwebsite.com/$1 [L, R=301] Routing slash is also part of canonicalization considering that URLs with a slash at the end or without are also treated differently. RewriteCond % !-f RewriteRule ^(. * [^/]$/$1/ [L, R=301] This will ensure the/ example-page is rerouted to/ example-page/. You might pick to eliminate the slash rather of adding then you will need the other guideline below: RewriteCond % REQUEST_FILENAME!-d RewriteRule ^(. *)/$/$1 [L, R=301]HTTP To HTTPS Redirect

After Google’s effort to encourage website owners to utilize SSL, migrating to HTTPS is one of the commonly used redirects that nearly every site has.

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

RewriteCond % ^ yourwebsite.com [NC, OR] RewriteCond % ^ www.yourwebsite.com [NC] RewriteRule ^(. *)$ https://www.yourwebsite.com/$1 [L, R=301, NC] Utilizing 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 used redirects when you decide to rebrand and require to change your domain. The rule 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 2 cases: one with the “www” variation of URLs and another “non-www” because any page for historical reasons might have incoming links to both variations.

Many website owners utilize WordPress and might not need a.htaccess file for redirects however use a plugin instead.

Managing redirects using plugins might be a little various from what we discussed above. You may require to read their documents to handle RegExp correctly for the particular plugin.

From the existing ones, I would suggest a free plugin called Redirection, which has many specifications to control redirect rules and many useful docs.

Reroute Finest Practices

1. Don’t Reroute All 404 Broken URLs To The Homepage

This case frequently happens when you are too lazy to examine your 404 URLs and map them to the proper landing page.

According to Google, they are still all dealt with as 404s.

If you have too many pages like this, you must think about producing lovely 404 pages and engaging users to browse further or find something besides what they were searching for by displaying a search choice.

It is strongly recommended by Google that redirected page material ought to be comparable to the old page. Otherwise, such a redirect may be thought about a soft 404, and you will lose the rank of that page.

2. Get Mobile Page-Specific Reroutes Right

If you have different URLs for desktop and mobile websites (i.e., “example.com” for desktop and “m.example.com” for mobile), you need to make certain to reroute users to the suitable page of the mobile version.

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

Likewise, you need to make sure that if one page is 404 on the desktop, it should likewise be 404 on mobile.

If you have no mobile variation 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 utilizing a meta refresh tag like the example below:

If you insert this tag in/ old-page/, it will reroute the user right away to/ new-page/.

Google does not restrict this redirect, however it does not advise using it.

According to John Mueller, online search engine may not have the ability to acknowledge that kind of redirect effectively. The exact same is also real about JavaScript redirects.

4. Prevent Redirect Chains

This message shows when you have a wrong routine expression setup and ends up in an unlimited loop.

Screenshot by author, December 2022 Typically, this takes place when you have a redirect chain. Let’s say you rerouted page 1 to page 2 a long time back. You may have forgotten that

page 1 is rerouted and chosen to reroute page 2 to page 1 once 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 produce an infinite loop and produce the error shown above. Conclusion Understanding what

redirects are and which circumstance needs a specific status code is fundamental to

enhancing

web pages properly. It’s a core part of understanding SEO. Lots of scenarios require accurate knowledge of redirects, such as migrating a site to a brand-new domain or creating a temporary holding page URL for a website that will return under its regular URL. While a lot is possible with a plugin, plugins can be misused without appropriately comprehending when and why to utilize a particular

kind of redirect. More Resources: Included Image: