URL Reroutes For SEO: A Technical Guide

Posted by

Reroutes for SEO should be used correctly because they impact how websites are crawled and indexed by Google.

While the majority of people think of redirects as a web detour sign, much more is occurring, and it’s remarkably enjoyable to discover.

Keep checking out for a comprehensive introduction of redirects and the correct application for technical SEO.

What Is A Redirect?

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

A URL redirect involves code executed to a particular 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:

  • Short-term redirect: 302, 303, 307, 308.
  • Long-term redirect: 301.

When To Use Redirects

The primary reasons to use redirects are:

  • An individual page or entire domain has been moved (URL altered).
  • To enable the usage of URL shorteners or ‘quite URLs.’
  • Website migration (e.g., HTTP to HTTPS).

For SEO purposes, URL redirects are very important since they:

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

Redirects can be executed on a group or domain-wide basis but often require to be set on an individual basis to prevent issues.

When using RegEX for group reroutes, it can have unanticipated outcomes if your logic isn’t perfect!

Types Of Redirects

There are three main kinds of redirects:

  • Meta Refresh redirects are set at the page level however are typically not recommended for SEO purposes. There are 2 kinds of meta redirect: delayed which is viewed as a momentary redirect, and instant, which is viewed as an irreversible redirect.
  • Javascript reroutes are likewise set on the client side’s page and can trigger SEO problems. Google has mentioned a preference for HTTP server-side redirects.
  • HTTP redirects are set server-side and the very best technique for SEO purposes– we covered thorough listed below.

What Is A HTTP Action Status Code?

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

When a user agent tries to access a website, what occurs is that the user agent makes a demand, and the website server concerns an action.

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

In the situation where a user representative like GoogleBot requests a URL, the server provides a reaction.

For example, if the ask for a URL succeeds, the server will supply a response code of 200, which implies the request for a URL achieved success.

So, when you think of a GoogleBot reaching a website and trying to crawl it, what’s taking place is a series of requests and reactions.

HTTP Reroutes

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

If the URL exists at a different URL (due to the fact that it was moved), the server informs the user representative that the URL request is being redirected to a different URL.

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

The whole 3xx series of reaction codes communicate much details that can additionally be acted on by the user agent.

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 brand-new URL rather.

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

3XX Series Of Status Codes

Redirects are more than simply the 2 status codes everybody recognizes with, the 301 and 302 action codes.

There are a total of 7 official 3xx reaction status codes.

These are the various type of redirects offered for use:

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

Some of the above status codes have not been around as long and might not be used. So, prior to using any redirect code besides 301 or 302, make certain that the intended user agent can analyze it.

Because GoogleBot utilizes the latest version of Chrome (called a headless internet browser), it’s simple to inspect if a status code works by examining if Chrome recognizes the status code with a browser compatibility list.

For SEO, one should stay with using the 301 and 302 action codes unless there is a specific reason to utilize among the other codes.

301: Moved Completely

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

The 301 redirect shows to a user representative that the URL (in some cases described as a target resource or merely resource) was changed to another area which it should utilize the brand-new URL for future requests.

As pointed out earlier, there is more info as well.

The 301 status code also recommends to the user agent:

  • Future ask for the URL ought to be made with the new URL.
  • Whoever is making the demand should upgrade their links to the brand-new URL.
  • Subsequent requests can be altered from GET to POST.

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

“Keep in mind: For historic factors, a user representative MAY change the demand method from POST to GET for the subsequent demand. If this behavior is unwanted, the 308 (Irreversible 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 should beware when utilizing a 301 redirect. The 301 redirects need to only be used when the modification to a brand-new URL is permanent.

The 301 status code need to not be utilized when the change is momentary.

Furthermore, if you change your mind later on and go back to the old URL, the old URL might not rank any longer and might require time to regain the rankings.

So, the main point to bear in mind is that a 301 status code will be used when the change is irreversible.

302: Found

The main point to understand about the 302 status code is that it’s useful for circumstances where a URL is temporarily altered.

The significance of this reaction code is that the URL is briefly at a different URL, and it is suggested to utilize the old URL for future demands.

The 302 redirect status code likewise includes a technical caution associated to GET and Post:

“Keep in mind: For historic factors, a user representative MAY change the request method from POST to GET for the subsequent request. If this behavior is undesirable, the 307 (Momentary Redirect) status code can be used rather.”

The referral to “historical factors” may describe old or buggy user agents that might change the request approach.

307: Temporary Redirect

A 307 redirect implies the requested URL is temporarily moved, and the user agent ought to use the initial URL for future demands.

The only distinction in between a 302 and a 307 status code is that a user agent must request the brand-new URL with the same HTTP demand utilized to request the initial URL.

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

The Mozilla paperwork of the 307 status code discusses it more clearly than the main paperwork.

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

This has the same semantics as the 302 Found HTTP response code, with the exception that the user agent need to not change the HTTP technique utilized: if a POST was utilized in the very first demand, a POST needs to be utilized in the 2nd demand.”

Aside from the 307 status code needing subsequent requests to be of the exact same kind (POST or GET) which the 302 can go in either case, everything else is the same between the 302 and the 307 status codes.

302 Vs. 307

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

In all circumstances, they have the exact same syntax for writing redirect rules. They differ just with commands used in configuration files. For example, a redirect on Apache will look like this:

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

(You can read about symlinks here.)

On Nginx servers, it will look like this:

rewrite ^/ oldfolder// newfolder/ irreversible;

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

For instance:

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

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

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

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

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

Options +FollowSymlinks RewriteEngine on

Read the official documentation to read more about the RewriteEngine.

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

* no or more times
+ One or more times
. any single character
? Zero 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 utilized when calling $1

How To Create Redirects

How To Create A Redirect For A Single URL

The most typical and widely utilized kind of redirect is when deleting pages or altering URLs.

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

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

We might likewise utilize (. *), i.e., ^/ old-page(. *), but the issue is, if you have another page with a similar URL like/ old-page-other/, it will also be redirected when we only wish to reroute/ 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 brand-new one. If we use reroute in the list below type:

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

Without regular expressions, all URLs with UTM question string, e.g.,/ old-page? utm_source=facebook.com (which prevails because URLs are used to be shared over a social network), would end up as 404s.

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

Redirect All Except

Let’s say 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” guideline here.

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

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

Directory Change

You can use the guideline listed below if you did a classification restructuring and wish to move everything 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 used $1 in the target to inform the server that it must remember whatever in the URL that follows/ old-directory/ (i.e.,/ old-directory/subdirectory/) and pass it (i.e., “/ subdirectory/”) onto the location. As an outcome, it will be rerouted to/ new-directory/subdirectory/.

I utilized 2 guidelines: one case with no routing slash at the end and the other one with a trailing 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 asked for URL with no 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 state you have 100 URLs on your website with the city name “Chicago” and wish to remove 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 type 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, you may threaten your website with duplicate content issues since online search engine treat URLs with “www” and “non-www” versions as different pages with the exact same material.

For that reason, you should guarantee you run the site only with one variation you select.

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” version: 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 likewise dealt with in a different way. RewriteCond % REQUEST_FILENAME!-f RewriteRule ^(. * [^/]$/$1/ [L, R=301] This will make sure the/ example-page is redirected to/ example-page/. You may select to remove the slash instead of including then you will require the other guideline listed below: RewriteCond % !-d RewriteRule ^(. *)/$/$1 [L, R=301]HTTP To HTTPS Redirect

After Google’s initiative to motivate site owners to use SSL, migrating to HTTPS is one of the frequently used redirects that almost every website has.

The rewrite guideline listed below can be utilized to require HTTPS on every site.

RewriteCond % ^ yourwebsite.com [NC, OR] RewriteCond % ^ www.yourwebsite.com [NC] RewriteRule ^(. *)$ https://www.yourwebsite.com/$1 [L, R=301, NC] Utilizing this, you can combine a www or non-www variation reroute into one HTTPS redirect guideline.

Redirect From Old Domain To New

This is likewise one of the most secondhand redirects when you decide to rebrand and require to change your domain. The rule listed below reroutes 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 uses 2 cases: one with the “www” variation of URLs and another “non-www” since any page for historical factors may have incoming links to both versions.

Most site owners use WordPress and may not need a.htaccess declare redirects however use a plugin rather.

Managing redirects using plugins might be slightly various from what we discussed above. You may need to read their paperwork to handle RegExp correctly for the specific plugin.

From the existing ones, I would recommend a free plugin called Redirection, which has numerous parameters to control redirect rules and lots of useful docs.

Reroute Best Practices

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

This case typically takes place when you are too lazy to investigate your 404 URLs and map them to the suitable landing page.

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

If you have too many pages like this, you must consider developing stunning 404 pages and engaging users to browse additional or discover something other than what they were searching for by showing a search option.

It is strongly advised 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 sites (i.e., “example.com” for desktop and “m.example.com” for mobile), you need to ensure to redirect users to the appropriate 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 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 below:

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

Google does not restrict this redirect, but it does not advise utilizing it.

According to John Mueller, online search engine may not be able to recognize that type of redirect properly. The same is also real about JavaScript reroutes.

4. Prevent Redirect Chains

This message displays when you have a wrong regular expression setup and ends up in an unlimited 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 very long time ago. You may have forgotten that

page 1 is redirected and decided to reroute page 2 to page 1 once again. As a result, you will wind up with a guideline like this: RewriteRule ^ page1/ page2 [R

=301, NC, L] RewriteRule ^ page2/ page1 [R=301, NC, L] This will develop a limitless loop and produce the mistake revealed above. Conclusion Knowing what

redirects are and which situation needs a specific status code is essential to

optimizing

websites correctly. It’s a core part of comprehending SEO. Lots of scenarios need accurate knowledge of redirects, such as migrating a site to a new domain or developing a short-lived holding page URL for a website that will return under its regular URL. While so much is possible with a plugin, plugins can be misused without properly comprehending when and why to use a specific

kind of redirect. More Resources: Included Image: