URL Reroutes For SEO: A Technical Guide

Posted by

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

While many people consider redirects as a web detour sign, far more is happening, and it’s remarkably pleasurable to find.

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

What Is A Redirect?

Website redirects tell internet browsers and search engines info about a URL and where to find the webpage.

A URL redirect involves code executed to a particular URL, or a group of URLs so that the user (or 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.
  • Long-term redirect: 301.

When To Use Redirects

The primary reasons to utilize redirects are:

  • An individual page or whole domain has been moved (URL changed).
  • To enable the use of URL shorteners or ‘pretty URLs.’
  • Website migration (e.g., HTTP to HTTPS).

For SEO functions, URL redirects are necessary 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 discovered errors (although often it is much better to leave a 404).

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

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

Types Of Redirects

There are 3 main kinds of redirects:

  • Meta Refresh redirects are set at the page level however are normally not advised for SEO functions. There are 2 types of meta redirect: postponed which is seen as a short-term redirect, and immediate, which is viewed as a permanent redirect.
  • Javascript reroutes are also set on the customer side’s page and can trigger SEO issues. Google has mentioned a choice for HTTP server-side redirects.
  • HTTP redirects are set server-side and the best technique for SEO functions– we covered extensive listed below.

What Is A HTTP Response Status Code?

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

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

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

In the circumstance where a user agent like GoogleBot demands a URL, the server gives an action.

For instance, if the ask for a URL succeeds, the server will offer a reaction code of 200, which suggests the ask for a URL was successful.

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

HTTP Reroutes

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

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

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

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

3XX Series Of Status Codes

Redirects are more than just the two status codes everyone recognizes with, the 301 and 302 response codes.

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

These are the different sort of redirects offered for usage:

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

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

Because GoogleBot utilizes the current version of Chrome (called a headless browser), it’s simple to check if a status code is compatible by checking if Chrome acknowledges the status code with a web browser compatibility list.

For SEO, one ought to stay with using the 301 and 302 action codes unless there is a specific reason to use among the other codes.

301: Moved Completely

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

The 301 redirect indicates to a user representative that the URL (in some cases described as a target resource or simply resource) was altered to another place and that it need to utilize the brand-new URL for future requests.

As discussed earlier, there is more details too.

The 301 status code also suggests to the user agent:

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

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

“Note: For historical reasons, a user agent MAY change the demand technique from POST to GET for the subsequent request. If this habits is unwanted, the 308 (Long-term Redirect) status code can be used 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 take care when utilizing a 301 redirect. The 301 redirects should just be used when the change to a new URL is irreversible.

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

In addition, if you alter your mind later on and go back to the old URL, the old URL might not rank anymore and might take time to regain the rankings.

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

302: Found

The main thing to comprehend about the 302 status code is that it works for situations where a URL is momentarily altered.

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

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

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

The recommendation to “historical factors” might refer to old or buggy user representatives that might alter the request technique.

307: Temporary Redirect

A 307 redirect indicates the requested URL is temporarily moved, and the user representative need to utilize the initial URL for future demands.

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

That implies if the user representative requests the page with a GET demand, then the user representative need to utilize a GET ask for the new short-lived URL and can not use the POST demand.

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

“The server sends this response to direct the customer to get the asked for resource at another URI with same technique that was utilized in the prior demand.

This has the exact same semantics as the 302 Found HTTP reaction code, with the exception that the user agent must not alter the HTTP technique utilized: if a POST was utilized in the first request, a POST should be used in the second request.”

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

302 Vs. 307

You may handle a redirect by means of 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 just with commands utilized in setup files. For example, a redirect on Apache will look like this:

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

(You can read about symlinks here.)

On Nginx servers, it will look like this:

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

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

For instance:

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

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 dealing with redirects) are enabled on your server.

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

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

Choices +FollowSymlinks RewriteEngine on

Read the main documentation for more information about the RewriteEngine.

To comprehend the examples below, you may describe the table below on RegExp basics.

* zero or more times
+ Several 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 commonly utilized kind of redirect is when erasing 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 two methods is that the first uses the Apache mod_rewrite module, and the 2nd uses mod_alias. It can be done using both approaches.

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 rerouted to/ new-page/.

We might likewise use (. *), i.e., ^/ old-page(. *), but the problem is, if you have another page with a similar URL like/ old-page-other/, it will likewise be redirected when we only want to reroute/ 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 reroute in the list below type:

Redirect 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 network), would end up as 404s.

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

Redirect All Except

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 require 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/ category/ on the 3rd 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 properties like “/ category/image. jpg,” it will also be rerouted to “/ final-subcategory/” and cause an image break.

Directory Change

You can use the guideline 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 utilized $1 in the target to tell 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 destination. As a result, it will be redirected to/ new-directory/subdirectory/.

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

I could combine them into one rule utilizing (/? |. *)$ 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 a question string (i.e., “/ old-directory? utm_source=facebook” would be rerouted 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 remove them.

For the URL http://yourwebiste.com/example-chicago-event/, the redirect guideline would be:

RewriteRule ^(. *)-chicago-(. *) http://% /$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://% SERVER_NAME/$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 duplicate content concerns since search engines deal with URLs with “www” and “non-www” versions as various pages with the same content.

Therefore, you must guarantee you run the website only with one version you select.

If you wish to run your website with the “www” version, utilize 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] Routing 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 sure the/ example-page is redirected to/ example-page/. You might choose to remove 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 use SSL, moving to HTTPS is among the commonly utilized redirects that practically every website has.

The reword rule below can be used to require 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 version reroute into one HTTPS redirect rule.

Redirect From Old Domain To New

This is also among the most used redirects when you choose 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 2 cases: one with the “www” variation of URLs and another “non-www” since any page for historic factors might have incoming links to both variations.

A lot of site owners use WordPress and may not need a.htaccess declare redirects but utilize a plugin instead.

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

From the existing ones, I would advise a complimentary plugin called Redirection, which has numerous specifications to control redirect rules and many helpful docs.

Reroute Best Practices

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

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

If you have a lot of pages like this, you must think about developing stunning 404 pages and engaging users to browse additional or find something besides what they were looking for by showing a search option.

It is highly advised by Google that rerouted page material must be comparable 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 various URLs for desktop and mobile websites (i.e., “example.com” for desktop and “m.example.com” for mobile), you need to ensure to redirect users to the suitable 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 guarantee 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 avoid rerouting to the mobile variation and keep them on the desktop page.

3. How To Use 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 reroute the user right away to/ new-page/.

Google does not prohibit this redirect, however it does not advise utilizing it.

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

4. Prevent Redirect Chains

This message displays when you have an incorrect routine expression setup and winds up in a limitless loop.

Screenshot by author, December 2022 Generally, this takes place when you have a redirect chain. Let’s state you redirected page 1 to page 2 a long time earlier. 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 wind up with a rule like this: RewriteRule ^ page1/ page2 [R

=301, NC, L] RewriteRule ^ page2/ page1 [R=301, NC, L] This will produce an infinite loop and produce the error shown above. Conclusion Understanding what

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

optimizing

web pages effectively. It’s a core part of comprehending SEO. Lots of situations need precise knowledge of redirects, such as moving a site to a brand-new domain or producing a temporary holding page URL for a webpage that will return under its normal URL. While so much is possible with a plugin, plugins can be misused without properly understanding when and why to utilize a specific

type of redirect. More Resources: Included Image: