URL Reroutes For SEO: A Technical Guide

Posted by

Redirects for SEO should be utilized properly due to the fact that they impact how websites are crawled and indexed by Google.

While most people think about redirects as an internet detour sign, a lot more is taking place, and it’s surprisingly enjoyable to discover.

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

What Is A Redirect?

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

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

A redirect can be set as a:

  • Short-lived redirect: 302, 303, 307, 308.
  • Permanent redirect: 301.

When To Utilize Redirects

The main factors to use redirects are:

  • A specific page or whole 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 essential since they:

  • Forward authority of any links indicating a page that has moved or been erased.
  • Avoid 404 page not found errors (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 typically require to be set on a private basis to avoid concerns.

When utilizing RegEX for group redirects, it can have unanticipated results if your logic isn’t flawless!

Kinds of Redirects

There are three primary types of redirects:

  • Meta Refresh redirects are set at the page level however are usually not suggested for SEO functions. There are 2 kinds of meta redirect: delayed which is viewed as a short-term redirect, and instant, which is viewed as a permanent redirect.
  • Javascript redirects are likewise set on the customer side’s page and can cause SEO issues. Google has actually stated a preference for HTTP server-side reroutes.
  • HTTP redirects are set server-side and the very best approach for SEO functions– we covered extensive listed below.

What Is A HTTP Reaction Status Code?

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

When a user agent attempts to access a website, what happens is that the user agent makes a request, and the website server issues an action.

The reaction is called an HTTP reaction status code. It supplies a status for the ask for a URL.

In the circumstance where a user agent like GoogleBot requests a URL, the server gives an action.

For instance, if the request for a URL succeeds, the server will provide a reaction code of 200, which suggests the ask for a URL was successful.

So, when you consider a GoogleBot reaching a website and attempting to crawl it, what’s happening is a series of demands and responses.

HTTP Redirects

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

If the URL exists at a various URL (due to the fact that it was moved), the server tells the user agent that the URL demand is being rerouted to a different URL.

The response code for a changed URL is normally in the type of a 301 or 302 action status code.

The entire 3xx series of reaction codes interact much information that can optionally be acted upon by the user representative.

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

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

3XX Series Of Status Codes

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

There are a total of seven official 3xx action status codes.

These are the different type of redirects offered for usage:

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

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

Due to the fact that GoogleBot utilizes the most recent version of Chrome (called a headless browser), it’s simple to examine if a status code works by checking if Chrome recognizes the status code with an internet browser compatibility list.

For SEO, one must stick to using the 301 and 302 reaction codes unless there is a particular factor to use among the other codes.

301: Moved Permanently

The 301 status code is routinely referenced as the 301 redirects. But the official name is 301 Moved Completely.

The 301 redirect suggests to a user representative that the URL (often described as a target resource or simply resource) was changed to another location which it should utilize the new URL for future requests.

As discussed previously, there is more details also.

The 301 status code also recommends to the user agent:

  • Future ask for the URL must be made with the new URL.
  • Whoever is making the request ought to update their links to the new URL.
  • Subsequent requests can be altered from GET to POST.

That last point is a technical problem. According to the official standards for the 301 status code:

“Keep in mind: For historical factors, a user representative MAY alter the demand method from POST to GET for the subsequent demand. 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 new one.

Before making a change, you need to take care when utilizing a 301 redirect. The 301 redirects need to only be utilized when the change to a brand-new URL is long-term.

The 301 status code need to not be used when the modification is short-term.

In addition, if you alter your mind later and go back to the old URL, the old URL might not rank anymore and might require time to regain the rankings.

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

302: Found

The main thing to comprehend about the 302 status code is that it works for circumstances where a URL is briefly altered.

The meaning of this action code is that the URL is temporarily at a different URL, and it is recommended to use the old URL for future demands.

The 302 redirect status code likewise features a technical caveat associated to GET and Post:

“Keep in mind: For historical reasons, a user representative MAY change the demand technique from POST to GET for the subsequent demand. If this behavior is undesired, the 307 (Momentary Redirect) status code can be utilized rather.”

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

307: Temporary Redirect

A 307 redirect suggests the requested URL is temporarily moved, and the user agent must utilize the initial URL for future demands.

The only difference in between a 302 and a 307 status code is that a user representative must request the new URL with the exact same HTTP demand utilized to request the original URL.

That implies if the user representative requests the page with a GET request, then the user agent should use a GET ask for the new short-term URL and can not use the POST demand.

The Mozilla documentation of the 307 status code explains it more clearly than the main documentation.

“The server sends this response to direct the customer to get the asked for resource at another URI with same technique that was used in the prior demand.

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

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

302 Vs. 307

You may 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 very same syntax for writing redirect rules. They vary only with commands utilized in setup files. For instance, 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/ irreversible;

The commands used 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. “reword.”

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

On Apache, guarantee that mod_rewrite and mod_alias modules (responsible for dealing with 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.

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

Alternatives +FollowSymlinks RewriteEngine on

Read the main documents for more information about the RewriteEngine.

To comprehend the examples listed below, you might describe the table below on RegExp fundamentals.

* zero or more times
+ Several times
. any single character
? Absolutely no or one time
^ Start of the string
$ End of the string
| b OR operadn” |” a or b
(z) keeps in mind 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 altering 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 distinction in between the two methods is that the very first uses the Apache mod_rewrite module, and the second usages mod_alias. It can be done using both approaches.

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

We could 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 also be redirected when we just wish 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 redirect any variation of the page URL to a brand-new one. If we utilize redirect in the following type:

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 network), would wind up as 404s.

Even/ old-page without a trailing slash “/” would end 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 wish to merge all subcategories into/ category/final-subcategory/. We need the “all except” rule here.

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

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

Directory Modification

You can utilize the guideline listed below if you did a category restructuring and want to move everything 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 tell the server that it need to 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 rerouted to/ new-directory/subdirectory/.

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

I could combine them into one rule utilizing (/? |. *)$ RegExp at the end, however it would trigger issues and include 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 redirected to “/ new-directory//? utm_source=facebook”).

Eliminate A Word From URL

Let’s state 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 guideline would be:

RewriteRule ^(. *)-chicago-(. *) http://% /$1-$2 [NC, R=301, L] If the example URL is in the type http://yourwebiste.com/example/chicago/event/, then the redirect would be: RewriteRule ^(. *)/ chicago/(. *) http://% SERVER_NAME/$1/$2 [NC, R=301, L] Set A Canonical URL

Having canonical URLs is the most vital part of SEO.

If missing, you might threaten your website with duplicate content concerns since online search engine treat URLs with “www” and “non-www” variations as various pages with the very same material.

Therefore, you must guarantee you run the website only with one version you pick.

If you wish to run your site with the “www” variation, utilize 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] Routing slash is likewise part of canonicalization considering that URLs with a slash at the end or without are also treated differently. RewriteCond % REQUEST_FILENAME!-f RewriteRule ^(. * [^/]$/$1/ [L, R=301] This will make sure the/ example-page is redirected to/ example-page/. You might pick to get rid of the slash instead of including then you will need the other rule listed 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 among the frequently used redirects that practically every site has.

The reword guideline below can be used to force HTTPS on every site.

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 combine a www or non-www variation reroute into one HTTPS redirect guideline.

Redirect From Old Domain To New

This is also among the most used redirects when you choose to rebrand and require to alter your domain. The rule below redirects old-domain. com to new-domain. com.

RewriteCond % HTTP_HOST ^ old-domain. com$ [OR] RewriteCond % ^ www.old-domain.com$ RewriteRule (. *)$ http://www.new-domain.com/$1 [R=301, L] It utilizes 2 cases: one with the “www” variation of URLs and another “non-www” due to the fact that any page for historic factors might have incoming links to both variations.

A lot of website owners utilize WordPress and may not require a.htaccess apply for redirects however utilize a plugin rather.

Managing redirects using plugins might be slightly various from what we went over above. You might need to read their documentation to manage RegExp correctly for the specific plugin.

From the existing ones, I would advise a free plugin called Redirection, which has numerous criteria to manage redirect rules and numerous useful docs.

Reroute Best Practices

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

This case typically occurs 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 dealt with as 404s.

If you have too many pages like this, you ought to consider producing lovely 404 pages and engaging users to search additional or discover something besides what they were looking for by showing a search alternative.

It is strongly suggested by Google that rerouted page material should 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 need to make sure to reroute 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 make sure that if one page is 404 on the desktop, it must 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 Use 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 right away to/ new-page/.

Google does not prohibit this redirect, but it doesn’t suggest utilizing it.

According to John Mueller, search engines might not be able to acknowledge that kind of redirect appropriately. The exact same is likewise true about JavaScript reroutes.

4. Avoid Redirect Chains

This message shows when you have an incorrect routine expression setup and winds up in an infinite loop.

Screenshot by author, December 2022 Generally, this occurs when you have a redirect chain. Let’s state you rerouted page 1 to page 2 a long time ago. You might have forgotten that

page 1 is rerouted and chosen to redirect page 2 to page 1 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 produce a limitless loop and produce the mistake revealed above. Conclusion Understanding what

redirects are and which scenario needs a particular status code is fundamental to


websites correctly. It’s a core part of understanding SEO. Lots of circumstances need precise knowledge of redirects, such as moving a site to a brand-new domain or creating 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 appropriately understanding when and why to utilize a particular

type of redirect. More Resources: Featured Image: