URL Reroutes For SEO: A Technical Guide

Posted by

Reroutes for SEO ought to be used properly due to the fact that they affect how sites are crawled and indexed by Google.

While many people consider redirects as an internet detour sign, a lot more is taking place, and it’s surprisingly satisfying to discover.

Keep reading for a thorough introduction of redirects and the proper application for technical SEO.

What Is A Redirect?

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

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

A redirect can be set as a:

  • Momentary redirect: 302, 303, 307, 308.
  • Permanent redirect: 301.

When To Utilize Redirects

The primary reasons to use redirects are:

  • An individual page or entire domain has actually been moved (URL altered).
  • To permit the use 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 indicating a page that has actually moved or been erased.
  • Avoid 404 page not discovered errors (although often it is much better to leave a 404).

Redirects can be executed on a group or domain-wide basis but frequently require to be set on a private basis to avoid issues.

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

Types Of Redirects

There are three main kinds of redirects:

  • Meta Refresh redirects are set at the page level however are usually not recommended for SEO purposes. There are two types of meta redirect: postponed which is viewed as a temporary redirect, and immediate, which is viewed as an irreversible redirect.
  • Javascript redirects are likewise set on the customer side’s page and can cause SEO concerns. Google has actually mentioned a choice for HTTP server-side reroutes.
  • HTTP redirects are set server-side and the very best technique for SEO purposes– we covered extensive listed below.

What Is A HTTP Action Status Code?

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

When a user representative attempts to access a web page, what occurs is that the user agent makes a demand, and the site server concerns a response.

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

In the scenario where a user agent like GoogleBot demands a URL, the server offers a reaction.

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

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

HTTP Reroutes

An HTTP redirect is a server action to request a URL.

If the URL exists at a various URL (since 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 usually in the form of a 301 or 302 action status code.

The whole 3xx series of response codes communicate much info 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 the brand-new URL instead.

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 just the 2 status codes everybody recognizes with, the 301 and 302 action codes.

There are a total of 7 main 3xx response status codes.

These are the different type of redirects available for use:

  • 300 Numerous Options.
  • 301 Moved Permanently.
  • 302 Found.
  • 303 See Other.
  • 304 Not Customized.
  • 305 Use Proxy.
  • 306 (Unused).
  • 307 Momentary Redirect.
  • 308 Permanent Redirect.

Some of the above status codes have not been around as long and may not be utilized. So, before utilizing any redirect code besides 301 or 302, make sure that the designated user agent can interpret it.

Because GoogleBot utilizes the most recent version of Chrome (called a headless browser), it’s easy to examine if a status code works by inspecting if Chrome recognizes the status code with an internet browser compatibility list.

For SEO, one ought to adhere to using the 301 and 302 action codes unless there is a specific factor to use one of the other codes.

301: Moved Permanently

The 301 status code is consistently referenced as the 301 redirects. But the main name is 301 Moved Permanently.

The 301 redirect suggests to a user representative that the URL (in some cases referred to as a target resource or just resource) was changed to another place and that it need to use the brand-new URL for future requests.

As discussed earlier, there is more info as well.

The 301 status code likewise suggests to the user agent:

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

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

“Note: For historic reasons, a user agent MAY change the demand technique from POST to GET for the subsequent request. If this behavior is undesirable, the 308 (Long-term 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.

Prior to making a modification, you should beware when utilizing 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 must not be used when the modification is momentary.

Additionally, if you alter your mind later and return to the old URL, the old URL might not rank any longer and might require time to gain back the rankings.

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

302: Found

The main thing to understand about the 302 status code is that it’s useful for scenarios where a URL is briefly changed.

The significance of this action code is that the URL is momentarily at a different URL, and it is suggested to use the old URL for future requests.

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

“Note: For historical reasons, a user representative MAY change the request approach from POST to GET for the subsequent request. If this habits is undesired, the 307 (Short-lived Redirect) status code can be used rather.”

The reference to “historical factors” might refer to old or buggy user agents that might alter the demand approach.

307: Temporary Redirect

A 307 redirect suggests the requested URL is briefly moved, and the user agent must use the original 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 new URL with the very same HTTP request used to ask for the initial URL.

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

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

“The server sends this action to direct the customer to get the asked for resource at another URI with very same approach that was utilized in the previous request.

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

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

302 Vs. 307

You might deal with a redirect by means of server config files.htaccess on Apache, example.conf file on Nginx or via plugins if you are using WordPress.

In all instances, they have the exact same syntax for writing redirect guidelines. They vary only with commands utilized in configuration files. For instance, a redirect on Apache will appear 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/ irreversible;

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 same for both.

On Apache, ensure that mod_rewrite and mod_alias modules (accountable for handling redirects) are allowed on your server.

Considering that the most commonly 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 guidelines listed below them:

Choices +FollowSymlinks RewriteEngine on

Read the official paperwork for more information about the RewriteEngine.

To understand the examples below, you may describe the table 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 used when calling $1

How To Produce Redirects

How To Create A Redirect For A Single URL

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

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

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

We might likewise use (. *), 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 just want 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 reroute any variation of the page URL to a new one. If we utilize reroute in the list below kind:

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

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

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

Redirect All Other than

Let’s state we have a bunch 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 except” rule here.

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

Otherwise, if we have some assets like “/ category/image. jpg,” it will likewise 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 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 need to keep in mind 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 rerouted to/ new-directory/subdirectory/.

I utilized 2 guidelines: one case without any tracking 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 trigger issues and add a “//” slash to the end of the URL when the requested URL without any tracking slash has an inquiry string (i.e., “/ old-directory? utm_source=facebook” would be redirected 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 remove 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 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 fundamental part of SEO.

If missing out on, you might threaten your site with duplicate content issues because online search engine treat URLs with “www” and “non-www” variations as different pages with the same content.

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

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

RewriteCond % HTTP_HOST ^ yourwebsite.com [NC] RewriteRule ^(. *)$ http://www.yourwebsite.com/$1 [L, R=301] For a “non-www” version: RewriteCond % ^ www.yourwebsite.com [NC] RewriteRule ^(. *)$ http://yourwebsite.com/$1 [L, R=301] Trailing slash is likewise part of canonicalization given that URLs with a slash at the end or without are likewise dealt with differently. RewriteCond % REQUEST_FILENAME!-f RewriteRule ^(. * [^/]$/$1/ [L, R=301] This will ensure the/ example-page is redirected to/ example-page/. You may select to eliminate the slash rather of including then you will require the other guideline listed below: RewriteCond % REQUEST_FILENAME!-d RewriteRule ^(. *)/$/$1 [L, R=301]HTTP To HTTPS Redirect

After Google’s initiative to motivate website owners to utilize SSL, migrating to HTTPS is one of the commonly used redirects that nearly every website has.

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

RewriteCond % ^ 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 integrate a www or non-www version reroute into one HTTPS redirect guideline.

Redirect From Old Domain To New

This is likewise among the most secondhand redirects when you decide to rebrand and need to alter your domain. The guideline listed below redirects old-domain. com to new-domain. com.

RewriteCond % HTTP_HOST ^ old-domain. com$ [OR] RewriteCond % HTTP_HOST ^ 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 historic reasons might have inbound links to both versions.

Most site owners utilize WordPress and may not need a.htaccess file for redirects but utilize a plugin rather.

Handling redirects utilizing plugins might be slightly various from what we discussed above. You may need to read their paperwork to handle RegExp properly for the particular plugin.

From the existing ones, I would suggest a totally free plugin called Redirection, which has lots of criteria to manage redirect rules and many helpful docs.

Reroute Best Practices

1. Do not 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 suitable landing page.

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

If you have too many pages like this, you ought to consider developing lovely 404 pages and engaging users to search further or discover something besides what they were trying to find by displaying a search choice.

It is strongly recommended by Google that redirected page content must be equivalent to the old page. Otherwise, such a redirect may 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 different URLs for desktop and mobile websites (i.e., “example.com” for desktop and “m.example.com” for mobile), you need to make sure to redirect users to the appropriate page of the mobile variation.

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

Likewise, you need to ensure that if one page is 404 on the desktop, it needs to likewise be 404 on mobile.

If you have no mobile version 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 using a meta refresh tag like the example listed below:

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

Google does not restrict this redirect, however it doesn’t recommend using it.

According to John Mueller, online search engine might not have the ability to acknowledge that type of redirect correctly. The very same is likewise true about JavaScript redirects.

4. Prevent Redirect Chains

This message shows when you have a wrong regular expression setup and winds up in a limitless loop.

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

page 1 is redirected and decided to redirect 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 create an infinite loop and produce the mistake shown above. Conclusion Understanding what

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


webpages effectively. It’s a core part of comprehending SEO. Numerous situations require exact knowledge of redirects, such as migrating a website to a brand-new domain or creating a short-lived holding page URL for a website that will return under its regular URL. While a lot is possible with a plugin, plugins can be misused without appropriately understanding when and why to utilize a particular

type of redirect. More Resources: Included Image: