URL Reroutes For SEO: A Technical Guide

Posted by

Reroutes for SEO ought to be utilized correctly because they impact how sites are crawled and indexed by Google.

While the majority of people think about redirects as an internet detour sign, much more is taking place, and it’s surprisingly satisfying to discover.

Keep checking out for an extensive summary of redirects and the appropriate application for technical SEO.

What Is A Redirect?

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

A URL redirect includes code implemented to a particular URL, or a group of URLs so that the user (or online 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:

  • Temporary redirect: 302, 303, 307, 308.
  • Irreversible redirect: 301.

When To Use Redirects

The primary factors to use redirects are:

  • An individual page or whole domain has actually been moved (URL changed).
  • To enable the usage of URL shorteners or ‘quite URLs.’
  • Site 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 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 but frequently require to be set on a private basis to prevent issues.

When using RegEX for group redirects, it can have unexpected results if your reasoning isn’t flawless!

Types Of Redirects

There are 3 primary kinds of redirects:

  • Meta Refresh redirects are set at the page level however are generally not advised for SEO purposes. There are 2 types of meta redirect: postponed which is seen as a short-lived redirect, and instant, which is seen as a permanent redirect.
  • Javascript redirects are also set on the client side’s page and can trigger SEO concerns. Google has stated a choice for HTTP server-side reroutes.
  • HTTP redirects are set server-side and the very best approach for SEO purposes– we covered in-depth below.

What Is A HTTP Reaction Status Code?

Browsers and search engine crawlers like GoogleBot are called user representatives.

When a user agent attempts to access a web page, what occurs is that the user agent makes a demand, and the site server problems an action.

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

In the scenario where a user agent like GoogleBot requests a URL, the server provides a reaction.

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

So, when you consider a GoogleBot reaching a site and attempting to crawl it, what’s taking place is a series of requests and responses.

HTTP Reroutes

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

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

The entire 3xx series of action codes communicate much information that can optionally 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 new URL so that the next time the old URL is requested, it will request the brand-new URL rather.

So, a 301 and a 302 redirect is more than an internet roadway indication that states, “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 action codes.

There are an overall of 7 main 3xx action status codes.

These are the different type of redirects readily available for usage:

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

A few of the above status codes have not been around as long and may not be utilized. So, prior to utilizing any redirect code besides 301 or 302, make certain that the intended user representative can analyze it.

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

For SEO, one need to stay with utilizing the 301 and 302 reaction codes unless there is a specific factor to use one of 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 shows to a user agent that the URL (often referred to as a target resource or just resource) was altered to another area which it must utilize the new URL for future demands.

As pointed out previously, there is more details also.

The 301 status code also recommends to the user agent:

  • Future ask for the URL should be made with the brand-new URL.
  • Whoever is making the request should upgrade 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 requirements for the 301 status code:

“Note: For historical reasons, a user agent MAY alter the demand approach from POST to GET for the subsequent demand. If this habits is undesirable, the 308 (Permanent Redirect) status code can be utilized rather.”

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

Before making a change, you should beware when using a 301 redirect. The 301 redirects must just be used when the change to a new URL is irreversible.

The 301 status code should 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 may take some time to regain the rankings.

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

302: Found

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

The meaning of this action code is that the URL is briefly at a various URL, and it is suggested to use the old URL for future demands.

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

“Note: For historical factors, a user agent MAY change the request method from POST to GET for the subsequent demand. If this habits is unwanted, the 307 (Momentary Redirect) status code can be utilized instead.”

The recommendation to “historic reasons” may refer to old or buggy user representatives that may change the request approach.

307: Temporary Redirect

A 307 redirect means the requested URL is temporarily moved, and the user representative ought to use the original URL for future requests.

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

That means if the user agent demands the page with a GET request, then the user representative should use a GET request for the brand-new temporary URL and can not use the POST request.

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

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

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

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

302 Vs. 307

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

In all instances, they have the very same syntax for writing redirect guidelines. They differ just with commands utilized in configuration files. For example, 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 look like this:

reword ^/ oldfolder// newfolder/ permanent;

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

For example:

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

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

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

Considering that the most commonly 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:

Alternatives +FollowSymlinks RewriteEngine on

Read the official documents to read more about the RewriteEngine.

To understand the examples listed below, you may describe 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) keeps in mind the match to be utilized when calling $1

How To Create Redirects

How To Produce A Redirect For A Single URL

The most common and extensively used type of redirect is when erasing 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 between the 2 methods is that the very first utilizes the Apache mod_rewrite module, and the second usages mod_alias. It can be done using both approaches.

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

We could 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 likewise be rerouted when we only 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 reroute any variation of the page URL to a brand-new one. If we use reroute in the list below type:

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

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

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

RewriteCond % REQUEST_URI!/ category/final-subcategory/ RewriteCond % REQUEST_FILENAME!-f RewriteRule ^(classification/)./ category/final-subcategory/ [R=301, L] Here, we want to redirect all under/ classification/ on the 3rd line except if it is/ category/final-subcategory/ on the fourth line. We also have the “!-f” rule on the second line, overlooking 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 trigger an image break.

Directory site Change

You can utilize the rule listed below if you did a classification restructuring and wish to move everything 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 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 an outcome, 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 trailing slash.

I could combine them into one rule using (/? |. *)$ RegExp at the end, however it would trigger problems and include a “//” slash to the end of the URL when the requested URL with no 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 site 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://% /$1-$2 [NC, R=301, L] If the example URL remains 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 vital part of SEO.

If missing, you may endanger your website with replicate content problems since online search engine treat URLs with “www” and “non-www” variations as different pages with the very same content.

Therefore, you must ensure you run the website just with one variation you select.

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

RewriteCond % HTTP_HOST ^ 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 also treated in a different way. RewriteCond % !-f RewriteRule ^(. * [^/]$/$1/ [L, R=301] This will make certain the/ example-page is redirected to/ example-page/. You may pick to remove the slash rather of adding then you will require the other guideline below: RewriteCond % REQUEST_FILENAME!-d RewriteRule ^(. *)/$/$1 [L, R=301]HTTP To HTTPS Redirect

After Google’s initiative to encourage site owners to use SSL, moving to HTTPS is one of the typically used redirects that almost every site has.

The reword rule 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 integrate a www or non-www variation redirect into one HTTPS redirect rule.

Redirect From Old Domain To New

This is also one of the most pre-owned redirects when you decide to rebrand and require to change your domain. The rule 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 two cases: one with the “www” variation of URLs and another “non-www” because any page for historical reasons may have inbound links to both versions.

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

Handling redirects using plugins may be a little different from what we discussed above. You may require to read their documentation to deal with RegExp correctly for the specific plugin.

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

Reroute Best Practices

1. Don’t 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 proper landing page.

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

If you have a lot of pages like this, you need to think about developing gorgeous 404 pages and engaging users to search additional or discover something besides what they were trying to find by displaying a search choice.

It is highly recommended by Google that redirected page material should be comparable 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 different URLs for desktop and mobile websites (i.e., “example.com” for desktop and “m.example.com” for mobile), you ought to ensure to redirect users to the proper page of the mobile version.

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

Also, you need to ensure 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 variation 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 redirect the user immediately to/ new-page/.

Google does not prohibit this redirect, however it does not suggest utilizing it.

According to John Mueller, search engines may not have the ability to recognize that kind of redirect appropriately. The exact same is likewise real about JavaScript reroutes.

4. Avoid Redirect Chains

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

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

page 1 is redirected and decided to reroute page 2 to page 1 once again. As an outcome, 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 produce an infinite loop and produce the mistake revealed above. Conclusion Understanding what

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


web pages correctly. It’s a core part of understanding SEO. Numerous scenarios require precise understanding of redirects, such as migrating a site to a brand-new domain or creating a momentary holding page URL for a web page that will return under its regular URL. While so much is possible with a plugin, plugins can be misused without appropriately understanding when and why to utilize a specific

type of redirect. More Resources: Featured Image: