URL Reroutes For SEO: A Technical Guide

Posted by

Reroutes for SEO ought to be utilized properly since they impact how websites are crawled and indexed by Google.

While most people think of redirects as a web detour sign, a lot more is happening, and it’s surprisingly satisfying to find.

Keep checking out for a thorough overview of redirects and the correct application for technical SEO.

What Is A Redirect?

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

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

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

When To Utilize Redirects

The main reasons to utilize redirects are:

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

For SEO purposes, URL redirects are essential since they:

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

Redirects can be carried out on a group or domain-wide basis but often need to be set on a private basis to avoid problems.

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

Kinds of Redirects

There are three main kinds of redirects:

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

What Is A HTTP Reaction Status Code?

Browsers and online search engine crawlers like GoogleBot are called user agents.

When a user agent tries to access a web page, what takes place is that the user representative makes a request, and the website server issues a reaction.

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

In the situation where a user representative like GoogleBot requests a URL, the server offers an action.

For example, if the request for a URL achieves success, the server will supply an action code of 200, which implies the request for a URL was successful.

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 responses.

HTTP Redirects

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

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

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

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

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 requested, it will request for the brand-new URL instead.

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

3XX Series Of Status Codes

Redirects are more than simply the two status codes everyone is familiar with, the 301 and 302 response codes.

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

These are the various type of redirects offered for usage:

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

Some of the above status codes have actually not been around as long and may not be used. So, prior to utilizing any redirect code aside from 301 or 302, make certain that the designated user agent can translate it.

Since GoogleBot utilizes the latest version of Chrome (called a headless internet browser), it’s simple to check if a status code works by inspecting if Chrome acknowledges the status code with an internet browser compatibility list.

For SEO, one must stay with using the 301 and 302 reaction codes unless there is a specific factor to utilize one of the other codes.

301: Moved Completely

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 agent that the URL (sometimes described as a target resource or just resource) was changed to another place which it must utilize the brand-new URL for future requests.

As mentioned previously, there is more info as well.

The 301 status code likewise suggests to the user agent:

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

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

“Note: For historical factors, a user agent MAY alter the request approach from POST to GET for the subsequent request. If this habits is undesired, the 308 (Long-term 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.

Prior to making a change, you should beware when using a 301 redirect. The 301 redirects need to only be utilized when the modification to a brand-new URL is long-term.

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

Furthermore, if you change your mind later and return to the old URL, the old URL may not rank any longer and may take time to regain the rankings.

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

302: Found

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

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

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

“Note: For historic factors, a user representative MAY alter the request technique from POST to GET for the subsequent demand. If this habits is undesirable, the 307 (Temporary Redirect) status code can be utilized instead.”

The referral to “historic reasons” might refer to old or buggy user representatives that might change the request technique.

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 requests.

The only difference between a 302 and a 307 status code is that a user representative need to ask for the brand-new URL with the exact same HTTP demand utilized to ask for the initial URL.

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

The Mozilla documents of the 307 status code discusses it more clearly than the official documentation.

“The server sends this reaction to direct the client to get the requested resource at another URI with very same technique that was used in the prior demand.

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

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

302 Vs. 307

You might manage a redirect by means of 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 very same syntax for writing redirect rules. They vary just with commands used in configuration 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/ long-term;

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

For instance:

  • Servers status code of redirect: “301 ″ vs. “irreversible.”
  • Action command: “RedirectMatch” vs. “reword.”

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

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

Since the most extensively 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 guidelines below them:

Alternatives +FollowSymlinks RewriteEngine on

Read the official documentation to read more about the RewriteEngine.

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

* absolutely 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 Develop A Redirect For A Single URL

The most typical and widely utilized type of redirect is when erasing pages or altering 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 distinction between the 2 techniques is that the very first uses the Apache mod_rewrite module, and the second usages mod_alias. It can be done using both techniques.

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 precise match must be rerouted to/ new-page/.

We might likewise utilize (. *), 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 just wish 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 redirect 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 regular expressions, all URLs with UTM inquiry string, e.g.,/ old-page? utm_source=facebook.com (which prevails since URLs are utilized to be shared over a social network), would end up as 404s.

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

Redirect All Other than

Let’s say 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 require the “all other than” rule here.

RewriteCond % REQUEST_URI!/ category/final-subcategory/ RewriteCond % !-f RewriteRule ^(classification/)./ category/final-subcategory/ [R=301, L] Here, we want to reroute all under/ category/ on the third line except if it is/ category/final-subcategory/ on the 4th line. We also have the “!-f” rule on the 2nd line, disregarding 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 Modification

You can use the rule listed below if you did a classification 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 utilized $1 in the target to tell the server that it must 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 rules: one case with no trailing slash at the end and the other one with a tracking slash.

I could combine them into one guideline using (/? |. *)$ RegExp at the end, but it would cause problems and add a “//” slash to the end of the URL when the requested URL without any trailing slash has an inquiry 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 want to eliminate 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 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 important part of SEO.

If missing out on, you might threaten your website with duplicate content issues because search engines treat URLs with “www” and “non-www” versions as various pages with the exact same material.

Therefore, you need to guarantee you run the site just with one variation you choose.

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

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 also part of canonicalization because 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 certain the/ example-page is rerouted to/ example-page/. You may select to remove the slash instead of including then you will need 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 among the frequently utilized redirects that nearly every site has.

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

RewriteCond % HTTP_HOST ^ 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 variation redirect into one HTTPS redirect rule.

Redirect From Old Domain To New

This is also among the most secondhand redirects when you choose to rebrand and require to change 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 utilizes 2 cases: one with the “www” variation of URLs and another “non-www” since any page for historical reasons might have inbound links to both variations.

Many site owners use WordPress and might not require a.htaccess file for redirects but use a plugin instead.

Dealing with redirects utilizing plugins might be slightly different from what we talked about above. You might require to read their documents to handle RegExp properly for the particular plugin.

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

Redirect 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 proper landing page.

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

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

It is strongly advised by Google that redirected page material ought to 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 various URLs for desktop and mobile websites (i.e., “example.com” for desktop and “m.example.com” for mobile), you need to ensure to redirect 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 have 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 redirecting 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 insert this tag in/ old-page/, it will redirect the user right away to/ new-page/.

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

According to John Mueller, online search engine might not be able to recognize that kind of redirect properly. The exact same is likewise true about JavaScript redirects.

4. Avoid Redirect Chains

This message shows when you have an incorrect regular expression setup and winds up in a limitless 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 very long time ago. You may have forgotten that

page 1 is redirected 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 create an unlimited loop and produce the error revealed above. Conclusion Knowing what

redirects are and which scenario requires a specific status code is fundamental to


websites correctly. It’s a core part of comprehending SEO. Numerous circumstances need exact knowledge of redirects, such as moving a website to a brand-new domain or creating a short-lived 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 effectively comprehending when and why to use a specific

type of redirect. More Resources: Included Image: