URL Reroutes For SEO: A Technical Guide

Posted by

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

While most people think about redirects as a web detour indication, far more is happening, and it’s remarkably enjoyable to discover.

Keep reading for a detailed summary of redirects and the appropriate application for technical SEO.

What Is A Redirect?

Site redirects tell browsers and online search engine info 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:

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

When To Utilize Redirects

The main reasons to utilize redirects are:

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

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

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

Redirects can be implemented on a group or domain-wide basis but frequently require to be set on an individual basis to prevent issues.

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

Types Of Redirects

There are 3 main types of redirects:

  • Meta Refresh redirects are set at the page level however are generally not suggested for SEO purposes. There are 2 types of meta redirect: delayed which is seen as a temporary redirect, and instant, which is seen as a long-term redirect.
  • Javascript redirects are likewise set on the customer side’s page and can trigger SEO problems. Google has stated a choice for HTTP server-side redirects.
  • HTTP redirects are set server-side and the very best approach for SEO functions– we covered thorough listed below.

What Is A HTTP Action Status Code?

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

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

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

In the situation where a user agent like GoogleBot demands 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 suggests the ask for a URL achieved success.

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

HTTP Redirects

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 tells the user representative that the URL request is being redirected to a various URL.

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

The entire 3xx series of reaction codes interact much details that can optionally 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 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 a web roadway sign that says, “Go here, not there.”

3XX Series Of Status Codes

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

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

These are the various type of redirects available for usage:

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

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

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

For SEO, one must stick to using the 301 and 302 response codes unless there is a particular reason to utilize one of the other codes.

301: Moved Completely

The 301 status code is routinely referenced as the 301 redirects. However the official name is 301 Moved Permanently.

The 301 redirect shows to a user representative that the URL (often referred to as a target resource or merely resource) was altered to another place which it must use the brand-new URL for future requests.

As discussed previously, there is more details as well.

The 301 status code also suggests to the user representative:

  • Future ask for the URL need to be made with the new URL.
  • Whoever is making the demand should 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 historical reasons, a user agent MAY alter the request technique from POST to GET for the subsequent demand. If this habits is undesired, the 308 (Irreversible 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.

Before making a change, you should take care when utilizing a 301 redirect. The 301 redirects must just be utilized when the modification to a brand-new URL is permanent.

The 301 status code must not be utilized when the modification is short-lived.

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

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

302: Found

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

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

The 302 redirect status code also features a technical caveat associated to GET and Post:

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

The recommendation to “historical factors” may describe old or buggy user representatives that may alter the demand technique.

307: Temporary Redirect

A 307 redirect means the asked for URL is temporarily moved, and the user agent must utilize the initial URL for future demands.

The only distinction between a 302 and a 307 status code is that a user representative must request the brand-new URL with the very same HTTP request used to request the original URL.

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

The Mozilla documentation of the 307 status code describes it more plainly than the official paperwork.

“The server sends this action to direct the customer to get the requested resource at another URI with exact same approach that was used in the prior request.

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

Other than the 307 status code requiring subsequent demands to be of the same kind (POST or GET) and that 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 may handle a redirect through server config files.htaccess on Apache, example.conf file on Nginx or through plugins if you are using WordPress.

In all circumstances, they have the 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:

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

(You can check out symlinks here.)

On Nginx servers, it will appear like this:

rewrite ^/ oldfolder// newfolder/ irreversible;

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

For example:

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

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

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

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

Options +FollowSymlinks RewriteEngine on

Read the main paperwork for more information about the RewriteEngine.

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

* absolutely 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) keeps in mind the match to be used when calling $1

How To Produce Redirects

How To Develop A Redirect For A Single URL

The most typical and commonly used kind of redirect is when deleting pages or changing URLs.

For example, 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 difference in between the two approaches is that the very first utilizes the Apache mod_rewrite module, and the second uses mod_alias. It can be done utilizing both techniques.

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

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

Redirect 301/ old-page// new-page/

Without routine 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 media), would end up as 404s.

Even/ old-page without a tracking slash “/” would end 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 combine all subcategories into/ category/final-subcategory/. We need the “all other than” rule here.

RewriteCond % !/ category/final-subcategory/ RewriteCond % !-f RewriteRule ^(classification/)./ category/final-subcategory/ [R=301, L] Here, we wish to redirect 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 2nd line, overlooking any file like images, CSS, or JavaScript files.

Otherwise, if we have some properties like “/ category/image. jpg,” it will also be rerouted to “/ final-subcategory/” and cause an image break.

Directory site Change

You can use the guideline below if you did a classification restructuring and want 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 utilized $1 in the target to inform the server that it must keep in mind everything 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 used 2 guidelines: one case with no tracking slash at the end and the other one with a routing slash.

I could combine them into one rule utilizing (/? |. *)$ RegExp at the end, but 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 rerouted to “/ new-directory//? utm_source=facebook”).

Get rid of 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 rule 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 important part of SEO.

If missing out on, you might threaten your website with replicate content problems because search engines treat URLs with “www” and “non-www” variations as different pages with the exact same content.

Therefore, you should ensure you run the site just with one variation you choose.

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

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 also part of canonicalization considering that URLs with a slash at the end or without are also dealt with in a different way. RewriteCond % REQUEST_FILENAME!-f RewriteRule ^(. * [^/]$/$1/ [L, R=301] This will make sure 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 encourage website owners to use SSL, migrating to HTTPS is among the typically used redirects that almost every site has.

The reword rule below can be used 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] Using 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 secondhand redirects when you choose to rebrand and need to change your domain. The rule below reroutes 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 uses two cases: one with the “www” version of URLs and another “non-www” since any page for historic reasons might have incoming links to both variations.

The majority of website owners utilize WordPress and may not need a.htaccess declare redirects but utilize a plugin rather.

Handling redirects using plugins may be a little different from what we talked about above. You may need to read their paperwork to deal with RegExp correctly for the specific plugin.

From the existing ones, I would recommend a complimentary plugin called Redirection, which has many parameters to manage redirect rules and numerous beneficial docs.

Reroute Finest Practices

1. Do not Reroute 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 dealt with as 404s.

If you have a lot of pages like this, you must consider creating stunning 404 pages and engaging users to search more or discover something other than what they were looking for by displaying a search option.

It is strongly advised by Google that redirected page content must be equivalent 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 different URLs for desktop and mobile websites (i.e., “example.com” for desktop and “m.example.com” for mobile), you need to ensure 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”

Also, you have 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 redirecting to the mobile variation and keep them on the desktop page.

3. How To Use Meta Refresh

It is possible to do a redirect utilizing a meta revitalize 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 advise utilizing it.

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

4. Prevent Redirect Chains

This message displays when you have an incorrect regular 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 state you rerouted page 1 to page 2 a very long time earlier. You might have forgotten that

page 1 is rerouted and decided to redirect page 2 to page 1 once again. As an outcome, you will wind 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 revealed above. Conclusion Understanding what

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


webpages properly. It’s a core part of comprehending SEO. Numerous scenarios require exact knowledge of redirects, such as migrating a website to a new domain or producing a short-term 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 effectively understanding when and why to utilize a specific

type of redirect. More Resources: Featured Image: