URL Reroutes For SEO: A Technical Guide

Posted by

Redirects for SEO ought to be utilized correctly since they affect how websites are crawled and indexed by Google.

While many people consider redirects as an internet detour indication, much more is happening, and it’s remarkably pleasurable to discover.

Keep reading for an extensive overview of redirects and the proper application for technical SEO.

What Is A Redirect?

Website reroutes inform web browsers and online search engine details about a URL and where to discover the website.

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

A redirect can be set as a:

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

When To Utilize Redirects

The primary reasons to use redirects are:

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

For SEO purposes, URL redirects are important since 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 better to leave a 404).

Redirects can be executed on a group or domain-wide basis however often need to be set on an individual basis to avoid problems.

When using RegEX for group redirects, it can have unanticipated outcomes 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 however are generally not advised for SEO functions. There are two types of meta redirect: delayed which is viewed as a temporary redirect, and immediate, which is viewed as a long-term redirect.
  • Javascript redirects are also set on the customer side’s page and can trigger SEO concerns. Google has actually specified a choice for HTTP server-side redirects.
  • HTTP redirects are set server-side and the best approach for SEO purposes– we covered thorough below.

What Is A HTTP Reaction Status Code?

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

When a user representative tries to access a web page, what occurs is that the user representative makes a request, and the website server issues a response.

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

In the circumstance where a user agent like GoogleBot demands a URL, the server provides a reaction.

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

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

HTTP Redirects

An HTTP redirect is a server response 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 demand is being rerouted to a various URL.

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

The entire 3xx series of action 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 save a cache of the brand-new URL so that the next time the old URL is asked for, it will ask for the new URL rather.

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

3XX Series Of Status Codes

Redirects are more than just the two status codes everybody recognizes with, the 301 and 302 reaction codes.

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

These are the various kinds of redirects available for use:

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

Some of the above status codes have actually not been around as long and may not be used. So, before utilizing any redirect code aside from 301 or 302, make sure that the desired user representative can analyze it.

Since GoogleBot utilizes the latest variation of Chrome (called a headless web browser), it’s simple to inspect if a status code is compatible by examining if Chrome recognizes the status code with a browser compatibility list.

For SEO, one must adhere to utilizing the 301 and 302 response 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. But the official name is 301 Moved Completely.

The 301 redirect shows to a user representative that the URL (sometimes referred to as a target resource or merely resource) was altered to another area and that it need to utilize the new URL for future demands.

As mentioned previously, there is more info also.

The 301 status code likewise suggests to the user representative:

  • Future requests for the URL must be made with the brand-new URL.
  • Whoever is making the request 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 concern. According to the main standards for the 301 status code:

“Keep in mind: For historic reasons, a user agent MAY change the request method from POST to GET for the subsequent demand. If this behavior is undesirable, 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.

Prior to making a change, you should be careful when using a 301 redirect. The 301 redirects need to just be used when the change to a brand-new URL is irreversible.

The 301 status code need to not be used when the change is temporary.

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

So, the main thing to keep in mind is that a 301 status code will be utilized when the modification is long-term.

302: Found

The main thing to comprehend about the 302 status code is that it works for situations where a URL is temporarily 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 requests.

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

“Keep in mind: For historical factors, a user representative MAY alter the request approach from POST to GET for the subsequent demand. If this habits is undesired, the 307 (Short-term Redirect) status code can be utilized rather.”

The referral to “historic factors” may refer to old or buggy user agents that might alter the request method.

307: Temporary Redirect

A 307 redirect indicates the requested URL is briefly moved, and the user agent need to utilize the initial URL for future demands.

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

That indicates if the user agent requests the page with a GET demand, then the user agent should utilize a GET ask for the brand-new momentary URL and can not utilize the POST request.

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

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

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

Other than the 307 status code requiring subsequent demands to be of the same kind (POST or GET) which the 302 can go in any case, everything else is the very same 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 via plugins if you are utilizing WordPress.

In all circumstances, they have the very same syntax for writing redirect rules. They vary just with commands utilized in setup files. For instance, a redirect on Apache will look like this:

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

(You can read about symlinks here.)

On Nginx servers, it will appear like this:

reword ^/ oldfolder// newfolder/ permanent;

The commands utilized 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 very same for both.

On Apache, make sure that mod_rewrite and mod_alias modules (responsible for managing redirects) are enabled on your server.

Since the most commonly spread server type is Apache, here are examples for.htaccess apache files.

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

Options +FollowSymlinks RewriteEngine on

Read the main documentation to learn more about the RewriteEngine.

To comprehend the examples listed below, you may describe the table listed below on RegExp basics.

* 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 used when calling $1

How To Produce Redirects

How To Create A Redirect For A Single URL

The most typical and widely utilized kind of redirect is when erasing pages or changing URLs.

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

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

We might likewise use (. *), i.e., ^/ old-page(. *), however the problem is, if you have another page with a comparable URL like/ old-page-other/, it will also be redirected when we just want 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 new one. If we utilize redirect in the list below kind:

Reroute 301/ old-page// new-page/

Without routine expressions, all URLs with UTM query string, e.g.,/ old-page? utm_source=facebook.com (which is common given that URLs are used to be shared over a social media network), would end up as 404s.

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

Redirect All Except

Let’s say we have a bunch of URLs like/ category/old-subcategory -1/,/ category/old-subcategory -2/,/ category/final-subcategory/ and want to merge all subcategories into/ category/final-subcategory/. We need the “all other than” rule here.

RewriteCond % !/ category/final-subcategory/ RewriteCond % REQUEST_FILENAME!-f RewriteRule ^(category/)./ category/final-subcategory/ [R=301, L] Here, we wish to reroute all under/ classification/ on the third line other than if it is/ category/final-subcategory/ on the 4th 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 redirected to “/ final-subcategory/” and trigger an image break.

Directory Modification

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 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 a result, it will be redirected to/ new-directory/subdirectory/.

I used two rules: one case without any routing 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 issues and add a “//” slash to the end of the URL when the asked for URL without any routing slash has a query string (i.e., “/ old-directory? utm_source=facebook” would be rerouted to “/ new-directory//? utm_source=facebook”).

Get rid of A Word From URL

Let’s say you have 100 URLs on your site with the city name “Chicago” and want 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 remains in the kind 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, you may endanger your site with duplicate content concerns since search engines deal with URLs with “www” and “non-www” variations as various pages with the exact same material.

For that reason, you should guarantee you run the site only with one version you choose.

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

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

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

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

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

Redirect From Old Domain To New

This is likewise one of the most pre-owned redirects when you choose to rebrand and require to alter your domain. The guideline below redirects old-domain. com to new-domain. com.

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

Many website owners use WordPress and might not need a.htaccess apply for redirects but use a plugin instead.

Dealing with redirects utilizing plugins might be slightly different from what we went over above. You might require to read their documents to deal with RegExp correctly for the particular plugin.

From the existing ones, I would recommend a totally free plugin called Redirection, which has many parameters to manage redirect guidelines and many useful docs.

Redirect Best Practices

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

This case often occurs when you are too lazy to examine 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 a lot of pages like this, you must consider developing lovely 404 pages and engaging users to search additional or discover something besides what they were searching for by displaying a search choice.

It is strongly recommended by Google that rerouted page material 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 various URLs for desktop and mobile websites (i.e., “example.com” for desktop and “m.example.com” for mobile), you should make sure to reroute users to the proper page of the mobile variation.

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

Likewise, you have to make sure that if one page is 404 on the desktop, it needs to also 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 revitalize tag like the example listed below:

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

Google does not forbid this redirect, however it doesn’t suggest using it.

According to John Mueller, online search engine may not have the ability to recognize that kind of redirect appropriately. The exact same is also true about JavaScript reroutes.

4. Prevent Redirect Chains

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

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

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

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

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


websites correctly. It’s a core part of comprehending SEO. Numerous scenarios require exact understanding of redirects, such as moving a site to a brand-new domain or creating a momentary holding page URL for a website that will return under its normal URL. While so much is possible with a plugin, plugins can be misused without correctly understanding when and why to utilize a particular

sort of redirect. More Resources: Featured Image: