URL Reroutes For SEO: A Technical Guide

Posted by

Redirects for SEO needs to be utilized correctly due to the fact that they affect how sites are crawled and indexed by Google.

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

Keep checking out for a thorough summary of redirects and the appropriate application for technical SEO.

What Is A Redirect?

Website redirects inform web browsers and online search engine details about a URL and where to find the website.

A URL redirect involves code executed to a specific URL, or a group of URLs so that the user (or search engine) is sent to a different 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 main reasons to utilize redirects are:

  • A private page or entire domain has been moved (URL changed).
  • To enable the usage of URL shorteners or ‘pretty 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 indicating a page that has actually moved or been deleted.
  • Avoid 404 page not found errors (although in some cases it is much better to leave a 404).

Redirects can be implemented on a group or domain-wide basis but frequently need to be set on a specific basis to prevent issues.

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

Types Of Redirects

There are 3 primary types of redirects:

  • Meta Refresh redirects are set at the page level but are typically not recommended for SEO functions. There are two types of meta redirect: postponed which is seen as a temporary redirect, and instant, which is seen as a long-term redirect.
  • Javascript redirects are also set on the customer side’s page and can trigger SEO issues. Google has actually stated a preference for HTTP server-side reroutes.
  • HTTP redirects are set server-side and the very best approach for SEO purposes– we covered thorough listed below.

What Is A HTTP Response Status Code?

Internet browsers and online search engine spiders like GoogleBot are called user representatives.

When a user agent tries to access a website, what takes place is that the user agent makes a request, and the website server problems a reaction.

The response is called an HTTP reaction status code. It provides a status for the ask for a URL.

In the situation where a user representative like GoogleBot requests a URL, the server provides an action.

For example, if the request for a URL achieves success, the server will offer an action code of 200, which implies the ask for a URL was successful.

So, when you think of a GoogleBot reaching a site and trying to crawl it, what’s occurring is a series of requests and responses.

HTTP Reroutes

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

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

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

The entire 3xx series of response codes communicate much information that can additionally be acted upon by the user representative.

An example of an action that the user representative can take is to save 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 instead.

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

3XX Series Of Status Codes

Redirects are more than simply the two status codes everyone is familiar with, the 301 and 302 response codes.

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

These are the different sort of redirects readily available for use:

  • 300 Numerous Options.
  • 301 Moved Completely.
  • 302 Found.
  • 303 See Other.
  • 304 Not Customized.
  • 305 Use Proxy.
  • 306 (Unused).
  • 307 Short-lived Redirect.
  • 308 Long-term Redirect.

A few of the above status codes have actually not been around as long and might not be used. So, before utilizing any redirect code besides 301 or 302, make sure that the desired user agent can analyze it.

Because GoogleBot uses the current variation of Chrome (called a headless browser), it’s simple to inspect if a status code works by inspecting if Chrome acknowledges the status code with a browser compatibility list.

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

301: Moved Completely

The 301 status code is regularly referenced as the 301 redirects. However the main name is 301 Moved Completely.

The 301 redirect shows to a user agent that the URL (in some cases referred to as a target resource or simply resource) was altered to another area which it must use the brand-new URL for future demands.

As discussed earlier, there is more information too.

The 301 status code likewise recommends to the user agent:

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

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

“Keep in mind: For historical factors, a user representative MAY change the demand method from POST to GET for the subsequent demand. If this behavior 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 modification, you need to take care when utilizing a 301 redirect. The 301 redirects should only be used when the change to a brand-new URL is permanent.

The 301 status code must not be used when the change is momentary.

Additionally, if you alter your mind later and return to the old URL, the old URL might not rank anymore and might take time to regain the rankings.

So, the main thing to keep in mind is that a 301 status code will be utilized when the change is long-term.

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 different URL, and it is recommended to utilize the old URL for future requests.

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

“Keep in mind: For historic factors, a user representative MAY change the request approach from POST to GET for the subsequent demand. If this habits is undesired, the 307 (Short-lived Redirect) status code can be utilized instead.”

The recommendation to “historic factors” may refer to old or buggy user representatives that might change the demand method.

307: Temporary Redirect

A 307 redirect suggests the asked for URL is momentarily moved, and the user representative ought to use the initial URL for future requests.

The only difference in between a 302 and a 307 status code is that a user representative must request the new URL with the exact same HTTP request used to request the original URL.

That means if the user agent requests the page with a GET request, then the user agent must utilize a GET request for the new short-term URL and can not use the POST request.

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

“The server sends this response to direct the client to get the asked for resource at another URI with exact same technique that was utilized in the previous request.

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

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

302 Vs. 307

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

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

(You can read about symlinks here.)

On Nginx servers, it will look like this:

reword ^/ oldfolder// newfolder/ irreversible;

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

For example:

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

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

On Apache, ensure that mod_rewrite and mod_alias modules (responsible for dealing with redirects) are enabled on your server.

Because the most commonly 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 listed below them:

Alternatives +FollowSymlinks RewriteEngine on

Read the official documents to find out 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
? Absolutely no 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 Develop Redirects

How To Produce A Redirect For A Single URL

The most typical and extensively utilized type of redirect is when erasing pages or altering URLs.

For example, state 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 distinction in between the two approaches is that the very first uses the Apache mod_rewrite module, and the 2nd usages mod_alias. It can be done utilizing both methods.

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

We could likewise utilize (. *), i.e., ^/ old-page(. *), but the issue is, if you have another page with a similar URL like/ old-page-other/, it will likewise be rerouted 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 redirect in the following kind:

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

Without regular expressions, all URLs with UTM inquiry string, e.g.,/ old-page? utm_source=facebook.com (which prevails considering that URLs are utilized to be shared over a social media 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 state we have a bunch 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 need the “all except” rule here.

RewriteCond % !/ 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 third 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 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 whatever from the old directory 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 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 redirected to/ new-directory/subdirectory/.

I used 2 rules: one case without any tracking slash at the end and the other one with a tracking slash.

I could combine them into one guideline using (/? |. *)$ RegExp at the end, but it would trigger issues and include a “//” slash to the end of the URL when the asked for URL with no routing 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 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 rule would be:

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

If missing out on, you may endanger your website with replicate content concerns because online search engine deal with URLs with “www” and “non-www” variations as various pages with the very same material.

Therefore, you need to guarantee you run the website just with one variation you choose.

If you want 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] Tracking slash is likewise part of canonicalization because URLs with a slash at the end or without are likewise treated in a different way. RewriteCond % !-f RewriteRule ^(. * [^/]$/$1/ [L, R=301] This will make sure the/ example-page is rerouted to/ example-page/. You may select to eliminate 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 website owners to use SSL, migrating to HTTPS is one of the commonly used redirects that practically every site has.

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

RewriteCond % ^ yourwebsite.com [NC, OR] RewriteCond % ^ www.yourwebsite.com [NC] RewriteRule ^(. *)$ https://www.yourwebsite.com/$1 [L, R=301, NC] Using this, you can combine a www or non-www variation reroute into one HTTPS redirect rule.

Redirect From Old Domain To New

This is also one of the most pre-owned redirects when you choose to rebrand and require to alter your domain. The guideline 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 2 cases: one with the “www” variation of URLs and another “non-www” due to the fact that any page for historical reasons may have incoming links to both versions.

Many site owners utilize WordPress and might not require a.htaccess declare redirects but use a plugin instead.

Handling redirects utilizing plugins may be slightly various from what we went over above. You may need to read their documents to manage RegExp properly for the particular plugin.

From the existing ones, I would suggest a free plugin called Redirection, which has numerous criteria to manage redirect rules and numerous beneficial docs.

Redirect Finest Practices

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

This case frequently 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 treated as 404s.

If you have a lot of pages like this, you should consider developing lovely 404 pages and engaging users to search more or discover something besides what they were looking for by displaying a search option.

It is strongly recommended by Google that rerouted page content must be equivalent to the old page. Otherwise, such a redirect might be considered 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 ensure to reroute users to the appropriate page of the mobile version.

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 also be 404 on mobile.

If you have no mobile variation for a page, you can prevent rerouting to the mobile variation and keep them on the desktop page.

3. How To Utilize Meta Refresh

It is possible to do a redirect using a meta revitalize tag like the example listed below:

If you place this tag in/ old-page/, it will reroute the user immediately to/ new-page/.

Google does not forbid this redirect, but it does not suggest using it.

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

4. Prevent Redirect Chains

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

Screenshot by author, December 2022 Usually, this happens 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 rerouted and decided to redirect page 2 to page 1 once 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 create a boundless loop and produce the mistake shown above. Conclusion Understanding what

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

optimizing

websites correctly. It’s a core part of understanding SEO. Lots of circumstances require accurate understanding of redirects, such as migrating a site to a new domain or creating a short-lived 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 correctly understanding when and why to use a particular

kind of redirect. More Resources: Featured Image: