URL Reroutes For SEO: A Technical Guide

Posted by

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

While the majority of people think about redirects as a web detour sign, far more is occurring, and it’s surprisingly pleasurable to find.

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

What Is A Redirect?

Site redirects inform web browsers and online search engine info about a URL and where to discover the webpage.

A URL redirect involves code carried out 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 real URL that was input or clicked.

A redirect can be set as a:

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

When To Utilize Redirects

The main factors to use redirects are:

  • An individual page or entire domain has 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 essential due to the fact that they:

  • Forward authority of any links pointing to a page that has moved or been deleted.
  • Avoid 404 page not found mistakes (although often it is better to leave a 404).

Redirects can be implemented on a group or domain-wide basis however typically require to be set on a private basis to avoid issues.

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

Types Of Redirects

There are 3 main types of redirects:

  • Meta Refresh redirects are set at the page level however are usually not suggested for SEO functions. There are two kinds of meta redirect: delayed which is viewed as a temporary redirect, and instant, which is seen as an irreversible 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 redirects.
  • HTTP redirects are set server-side and the best method for SEO functions– we covered thorough below.

What Is A HTTP Reaction Status Code?

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

When a user representative attempts to access a web page, what takes place is that the user agent makes a demand, and the website server problems a response.

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

In the situation where a user representative like GoogleBot demands a URL, the server gives an action.

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

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

HTTP Redirects

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

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

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

The whole 3xx series of reaction codes communicate much details that can optionally be acted on by the user agent.

An example of an action that the user representative 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 new URL rather.

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

3XX Series Of Status Codes

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

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

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

  • 300 Several Choices.
  • 301 Moved Permanently.
  • 302 Found.
  • 303 See Other.
  • 304 Not Customized.
  • 305 Use Proxy.
  • 306 (Unused).
  • 307 Short-lived Redirect.
  • 308 Irreversible Redirect.

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

Due to the fact that GoogleBot uses the latest version of Chrome (called a headless browser), it’s simple to check if a status code works by inspecting if Chrome recognizes the status code with a web browser compatibility list.

For SEO, one ought to adhere to using the 301 and 302 response codes unless there is a particular factor to utilize among the other codes.

301: Moved Permanently

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

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

As mentioned previously, there is more info as well.

The 301 status code likewise suggests to the user representative:

  • Future requests for the URL should 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 issue. According to the main requirements for the 301 status code:

“Keep in mind: For historical factors, a user agent MAY alter the request approach from POST to GET for the subsequent demand. If this behavior is unwanted, 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 be careful when utilizing a 301 redirect. The 301 redirects must only be used when the modification to a new URL is permanent.

The 301 status code need to not be utilized when the change is short-term.

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

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

302: Found

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

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

The 302 redirect status code also comes with a technical caution associated to GET and Post:

“Keep in mind: For historical reasons, a user representative MAY change the request technique from POST to GET for the subsequent request. If this behavior is undesirable, the 307 (Short-lived Redirect) status code can be used rather.”

The recommendation to “historic factors” might describe old or buggy user agents that may change the demand approach.

307: Temporary Redirect

A 307 redirect means the requested URL is briefly moved, and the user agent ought to utilize the original 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 brand-new URL with the exact same HTTP request utilized to request the initial URL.

That means if the user agent requests the page with a GET request, then the user representative need to utilize a GET ask for the brand-new temporary URL and can not use the POST request.

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

“The server sends this response to direct the client to get the asked for resource at another URI with exact 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 change the HTTP technique utilized: if a POST was used in the first request, a POST needs to be utilized in the 2nd request.”

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

302 Vs. 307

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

In all circumstances, they have the same syntax for composing redirect rules. They vary only with commands utilized in setup files. For example, 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 appear like this:

rewrite ^/ oldfolder// newfolder/ long-term;

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

For instance:

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

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

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

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

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

Choices +FollowSymlinks RewriteEngine on

Read the main paperwork to read more about the RewriteEngine.

To understand the examples below, you may refer to the table listed below on RegExp basics.

* zero or more times
+ One or more 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 Develop A Redirect For A Single URL

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

For example, 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 2 methods is that the very first uses the Apache mod_rewrite module, and the 2nd usages 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 specific match should be redirected to/ new-page/.

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

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

Without routine expressions, all URLs with UTM question string, e.g.,/ old-page? utm_source=facebook.com (which is common because URLs are utilized to be shared over a social media), would wind up as 404s.

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

Redirect All Other than

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 require the “all other than” guideline here.

RewriteCond % !/ category/final-subcategory/ RewriteCond % REQUEST_FILENAME!-f RewriteRule ^(category/)./ category/final-subcategory/ [R=301, L] Here, we want to redirect all under/ category/ 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 also be rerouted to “/ final-subcategory/” and cause 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 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 tell 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 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 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 trailing slash has an inquiry 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 state 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 rule would be:

RewriteRule ^(. *)-chicago-(. *) http://% SERVER_NAME/$1-$2 [NC, R=301, L] If the example URL is in the form 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 important part of SEO.

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

Therefore, you should ensure you run the site just with one version you select.

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

RewriteCond % HTTP_HOST ^ yourwebsite.com [NC] RewriteRule ^(. *)$ http://www.yourwebsite.com/$1 [L, R=301] For a “non-www” variation: RewriteCond % HTTP_HOST ^ www.yourwebsite.com [NC] RewriteRule ^(. *)$ http://yourwebsite.com/$1 [L, R=301] Trailing slash is likewise part of canonicalization because URLs with a slash at the end or without are likewise treated in a different way. RewriteCond % REQUEST_FILENAME!-f RewriteRule ^(. * [^/]$/$1/ [L, R=301] This will make certain the/ example-page is redirected to/ example-page/. You might pick to get rid of the slash instead of including then you will need the other guideline listed below: RewriteCond % !-d RewriteRule ^(. *)/$/$1 [L, R=301]HTTP To HTTPS Redirect

After Google’s effort to encourage site owners to use SSL, migrating to HTTPS is among the frequently used redirects that practically every site has.

The reword 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 variation reroute into one HTTPS redirect guideline.

Redirect From Old Domain To New

This is also one of 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 % ^ old-domain. com$ [OR] RewriteCond % ^ www.old-domain.com$ RewriteRule (. *)$ http://www.new-domain.com/$1 [R=301, L] It uses 2 cases: one with the “www” version of URLs and another “non-www” due to the fact that any page for historic factors might have incoming links to both variations.

The majority of site owners utilize WordPress and might not need a.htaccess file for redirects but utilize a plugin rather.

Handling redirects using plugins may be a little various from what we discussed above. You may need to read their paperwork to manage RegExp properly for the specific plugin.

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

Reroute Finest Practices

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

This case frequently occurs 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 too many pages like this, you ought to consider producing lovely 404 pages and engaging users to browse further or find something other than what they were looking for by displaying a search option.

It is strongly recommended by Google that rerouted page material should 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 Redirects Right

If you have different URLs for desktop and mobile sites (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 version.

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

Likewise, you have to guarantee that if one page is 404 on the desktop, it must 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 Use Meta Refresh

It is possible to do a redirect utilizing a meta refresh 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 restrict this redirect, however it doesn’t recommend utilizing it.

According to John Mueller, online search engine may not be able to recognize that type of redirect correctly. The very same is likewise true about JavaScript redirects.

4. Avoid 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 Normally, this occurs when you have a redirect chain. Let’s say you redirected page 1 to page 2 a long period of time earlier. You might have forgotten that

page 1 is redirected and decided to redirect page 2 to page 1 again. As a result, 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 produce a boundless loop and produce the mistake shown above. Conclusion Understanding what

redirects are and which situation requires a specific status code is essential to

enhancing

websites appropriately. It’s a core part of understanding SEO. Lots of scenarios require accurate understanding of redirects, such as migrating a website to a new domain or developing a short-term holding page URL for a web page that will return under its regular URL. While a lot is possible with a plugin, plugins can be misused without properly understanding when and why to use a particular

type of redirect. More Resources: Featured Image: