URL Reroutes For SEO: A Technical Guide

Posted by

Reroutes for SEO needs to be used properly due to the fact that they impact how websites are crawled and indexed by Google.

While many people think of redirects as a web detour indication, a lot more is occurring, and it’s surprisingly enjoyable to find.

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

What Is A Redirect?

Website reroutes inform browsers and online search engine info about a URL and where to find the website.

A URL redirect includes code executed 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-term redirect: 302, 303, 307, 308.
  • Long-term redirect: 301.

When To Utilize Redirects

The main reasons to use redirects are:

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

For SEO functions, URL redirects are important due to the fact that they:

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

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

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

Types Of Redirects

There are 3 primary kinds of redirects:

  • Meta Refresh redirects are set at the page level but are generally not recommended for SEO functions. There are 2 types of meta redirect: postponed which is seen as a short-lived redirect, and immediate, which is seen as a permanent redirect.
  • Javascript reroutes are likewise set on the client side’s page and can trigger SEO concerns. Google has specified a choice for HTTP server-side reroutes.
  • HTTP redirects are set server-side and the very 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 webpage, what happens is that the user agent makes a request, and the website server concerns a reaction.

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

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

For instance, if the request for a URL achieves success, the server will offer an action code of 200, which indicates the ask for a URL achieved success.

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

HTTP Reroutes

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

If the URL exists at a various URL (since it was moved), the server informs the user agent that the URL request is being rerouted to a various URL.

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

The whole 3xx series of action codes interact much info that can optionally be acted on by the user agent.

An example of an action that the user agent can take is to conserve a cache of the brand-new URL so that the next time the old URL is asked for, it will request the brand-new URL rather.

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

3XX Series Of Status Codes

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

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

These are the various type of redirects offered for usage:

  • 300 Multiple Choices.
  • 301 Moved Permanently.
  • 302 Found.
  • 303 See Other.
  • 304 Not Customized.
  • 305 Use Proxy.
  • 306 (Unused).
  • 307 Temporary Redirect.
  • 308 Long-term Redirect.

Some of the above status codes have actually not been around as long and might not be used. So, before using any redirect code other than 301 or 302, be sure that the intended user agent can analyze it.

Due to the fact that GoogleBot utilizes the current variation of Chrome (called a headless browser), it’s simple to examine if a status code is compatible by checking if Chrome acknowledges the status code with a browser compatibility list.

For SEO, one should adhere to 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 regularly referenced as the 301 redirects. But the main name is 301 Moved Permanently.

The 301 redirect indicates to a user agent that the URL (in some cases referred to as a target resource or merely resource) was altered to another area and that it must utilize the new URL for future demands.

As pointed out earlier, there is more details too.

The 301 status code likewise suggests to the user agent:

  • Future requests for the URL need to be made with the brand-new URL.
  • Whoever is making the demand needs to upgrade their links to the new URL.
  • Subsequent demands can be changed from GET to POST.

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

“Keep in mind: For historic reasons, a user representative MAY change the request method from POST to GET for the subsequent demand. If this behavior is undesirable, the 308 (Long-term Redirect) status code can be utilized instead.”

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 must beware when utilizing a 301 redirect. The 301 redirects need to only be utilized when the change to a brand-new URL is permanent.

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

Additionally, if you alter your mind later and go back to the old URL, the old URL might not rank anymore and may take some time to gain back the rankings.

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

302: Found

The main point to understand about the 302 status code is that it works for situations where a URL is briefly altered.

The meaning of this reaction code is that the URL is momentarily at a various URL, and it is recommended to utilize the old URL for future requests.

The 302 redirect status code also includes a technical caution related to GET and Post:

“Keep in mind: For historic reasons, a user representative MAY alter the request approach from POST to GET for the subsequent request. If this behavior is undesirable, the 307 (Temporary Redirect) status code can be used instead.”

The referral to “historical reasons” may refer to old or buggy user representatives that may alter the request approach.

307: Temporary Redirect

A 307 redirect implies the requested URL is briefly moved, and the user agent need to use the initial URL for future requests.

The only distinction in between a 302 and a 307 status code is that a user representative should ask for the new URL with the same HTTP request utilized to request the initial URL.

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

The Mozilla documentation of the 307 status code discusses it more plainly than the main documents.

“The server sends this reaction to direct the customer to get the requested resource at another URI with very same method 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 representative should not alter the HTTP technique utilized: if a POST was used in the very first request, a POST needs to be used in the 2nd demand.”

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

302 Vs. 307

You might deal with 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 same syntax for writing redirect rules. They vary only with commands utilized in setup files. For instance, a redirect on Apache will look like this:

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

(You can read about symlinks here.)

On Nginx servers, it will look like this:

rewrite ^/ oldfolder// newfolder/ permanent;

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

For example:

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

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

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

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

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

Choices +FollowSymlinks RewriteEngine on

Read the main documents to find out more about the RewriteEngine.

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

* no or more times
+ Several times
. any single character
? Zero or one time
^ Start of the string
$ End of the string
| b OR operadn” |” a or b
(z) remembers the match to be utilized when calling $1

How To Produce Redirects

How To Create A Redirect For A Single URL

The most typical and extensively used kind of redirect is when deleting pages or altering URLs.

For instance, state 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 difference in 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 methods.

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

We could likewise use (. *), i.e., ^/ old-page(. *), however the issue is, if you have another page with a comparable URL like/ old-page-other/, it will also be rerouted when we just want to redirect/ 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 reroute any variation of the page URL to a new one. If we use reroute 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 since URLs are utilized to be shared over a social media 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 merge all subcategories into/ category/final-subcategory/. We need the “all except” rule here.

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

Directory site Modification

You can use the rule below if you did a classification restructuring and wish to move whatever 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 used $1 in the target to inform 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 rerouted to/ new-directory/subdirectory/.

I utilized two rules: one case without any routing slash at the end and the other one with a routing slash.

I could integrate them into one rule using (/? |. *)$ RegExp at the end, however it would cause issues and include a “//” slash to the end of the URL when the asked for URL with no tracking slash has an inquiry string (i.e., “/ old-directory? utm_source=facebook” would be redirected to “/ new-directory//? utm_source=facebook”).

Eliminate A Word From URL

Let’s say 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://% SERVER_NAME/$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 fundamental part of SEO.

If missing out on, you may endanger your site with duplicate content problems since search engines treat URLs with “www” and “non-www” variations as various pages with the very same material.

For that reason, you must guarantee you run the site just with one variation you select.

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” version: RewriteCond % HTTP_HOST ^ www.yourwebsite.com [NC] RewriteRule ^(. *)$ http://yourwebsite.com/$1 [L, R=301] Routing slash is likewise part of canonicalization since URLs with a slash at the end or without are also dealt with differently. RewriteCond % !-f RewriteRule ^(. * [^/]$/$1/ [L, R=301] This will make certain the/ example-page is rerouted to/ example-page/. You may choose to remove the slash rather of adding then you will require the other guideline below: RewriteCond % !-d RewriteRule ^(. *)/$/$1 [L, R=301]HTTP To HTTPS Redirect

After Google’s initiative to motivate website owners to use SSL, moving to HTTPS is among the commonly used redirects that nearly every site has.

The rewrite rule listed below can be used 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 reroute into one HTTPS redirect rule.

Redirect From Old Domain To New

This is likewise one of the most pre-owned redirects when you decide to rebrand and require to alter your domain. The rule below reroutes 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” due to the fact that any page for historic factors may have incoming links to both versions.

A lot of site owners utilize WordPress and might not require a.htaccess apply for redirects but use a plugin rather.

Handling redirects utilizing plugins might be a little different from what we talked about above. You might need to read their paperwork to handle RegExp properly for the specific plugin.

From the existing ones, I would advise a free plugin called Redirection, which has numerous parameters to control redirect guidelines and many useful docs.

Reroute Finest Practices

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

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

If you have a lot of pages like this, you should consider developing lovely 404 pages and engaging users to search further or find something other than what they were searching for by showing a search choice.

It is highly advised by Google that redirected page content should be comparable to the old page. Otherwise, such a redirect might be thought about 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 ought to make certain to reroute users to the proper page of the mobile version.

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

Also, you have to ensure that if one page is 404 on the desktop, it must likewise 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 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 restrict this redirect, but it does not recommend utilizing it.

According to John Mueller, online search engine may not have the ability to recognize that kind of redirect effectively. The very same is likewise real about JavaScript reroutes.

4. Prevent Redirect Chains

This message shows when you have a wrong routine expression setup and ends up in an infinite loop.

Screenshot by author, December 2022 Usually, this takes place when you have a redirect chain. Let’s say you rerouted page 1 to page 2 a very long time earlier. You may have forgotten that

page 1 is rerouted and chosen to reroute page 2 to page 1 once 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 develop an unlimited loop and produce the error shown above. Conclusion Knowing what

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


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

kind of redirect. More Resources: Included Image: