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 the majority of people think about redirects as a web detour sign, far more is happening, and it’s surprisingly satisfying to discover.

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

What Is A Redirect?

Site redirects inform internet browsers and online search engine details about a URL and where to find the webpage.

A URL redirect involves code implemented to a particular 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:

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

When To Use Redirects

The main factors to utilize redirects are:

  • A private page or entire domain has been moved (URL changed).
  • To permit the use of URL shorteners or ‘pretty URLs.’
  • Site migration (e.g., HTTP to HTTPS).

For SEO functions, URL redirects are important because they:

  • Forward authority of any links pointing to a page that has actually moved or been deleted.
  • Avoid 404 page not discovered mistakes (although sometimes 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 an individual basis to prevent problems.

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

Types Of Redirects

There are three primary types of redirects:

  • Meta Refresh redirects are set at the page level however are usually not advised for SEO purposes. There are two types of meta redirect: delayed which is seen as a short-lived redirect, and immediate, which is seen as a permanent redirect.
  • Javascript reroutes are likewise set on the customer side’s page and can cause SEO problems. Google has mentioned a choice for HTTP server-side reroutes.
  • HTTP redirects are set server-side and the best method for SEO purposes– we covered in-depth below.

What Is A HTTP Reaction Status Code?

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

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

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

In the scenario where a user agent like GoogleBot requests a URL, the server gives a response.

For example, if the request for a URL is successful, the server will supply a response code of 200, which indicates the request for a URL achieved success.

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

HTTP Reroutes

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

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

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

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

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 asked for, it will request for the brand-new URL instead.

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

3XX Series Of Status Codes

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

There are an overall of 7 main 3xx reaction status codes.

These are the different sort of redirects available for usage:

  • 300 Numerous Options.
  • 301 Moved Permanently.
  • 302 Found.
  • 303 See Other.
  • 304 Not Modified.
  • 305 Use Proxy.
  • 306 (Unused).
  • 307 Temporary 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 aside from 301 or 302, be sure that the designated user agent can analyze it.

Since GoogleBot uses the latest variation 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 browser compatibility list.

For SEO, one must stay with utilizing the 301 and 302 action codes unless there is a specific reason to utilize one of the other codes.

301: Moved Permanently

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

The 301 redirect indicates to a user agent that the URL (in some cases described as a target resource or merely resource) was altered to another area and that it need to use the brand-new URL for future demands.

As pointed out previously, there is more info too.

The 301 status code also suggests to the user representative:

  • Future ask for the URL ought to be made with the new URL.
  • Whoever is making the demand needs to upgrade 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 official requirements for the 301 status code:

“Keep in mind: For historic factors, a user representative MAY alter the demand method from POST to GET for the subsequent demand. If this habits is unwanted, the 308 (Long-term Redirect) status code can be used rather.”

For SEO, when search engines see a 301 redirect, they pass the old page’s ranking to the brand-new one.

Prior to making a change, you need to take care when utilizing a 301 redirect. The 301 redirects must just be used when the modification to a brand-new URL is irreversible.

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

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 require time to gain back the rankings.

So, the main point to remember is that a 301 status code will be used when the modification is long-term.

302: Found

The main point to comprehend about the 302 status code is that it works for circumstances where a URL is briefly changed.

The meaning of this response code is that the URL is briefly at a different URL, and it is suggested 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 historical factors, a user agent MAY change the demand technique from POST to GET for the subsequent demand. If this habits is unwanted, the 307 (Temporary Redirect) status code can be utilized rather.”

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

307: Temporary Redirect

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

The only distinction in between a 302 and a 307 status code is that a user representative must ask for the brand-new URL with the exact same HTTP demand utilized to request the initial URL.

That indicates if the user representative requests the page with a GET demand, then the user agent must utilize a GET request for the brand-new momentary URL and can not utilize the POST request.

The Mozilla documentation of the 307 status code discusses it more clearly than the main documentation.

“The server sends this action to direct the client to get the requested resource at another URI with same method that was used in the prior demand.

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 technique utilized: if a POST was utilized in the very first request, a POST needs to be used in the 2nd demand.”

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

302 Vs. 307

You may deal with 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 very same syntax for writing redirect rules. They differ just with commands utilized in configuration files. For instance, a redirect on Apache will look like this:

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

(You can check out symlinks here.)

On Nginx servers, it will look like this:

reword ^/ oldfolder// newfolder/ permanent;

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. “permanent.”
  • Action command: “RedirectMatch” vs. “rewrite.”

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

On Apache, make sure that mod_rewrite and mod_alias modules (accountable for handling redirects) are enabled on your server.

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

Choices +FollowSymlinks RewriteEngine on

Read the main documentation to find out more about the RewriteEngine.

To comprehend the examples listed below, you might describe the table below on RegExp essentials.

* no 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 utilized when calling $1

How To Develop Redirects

How To Produce A Redirect For A Single URL

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

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

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

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

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

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

Even/ old-page without a routing slash “/” would wind 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 wish to combine all subcategories into/ category/final-subcategory/. We need the “all except” guideline here.

RewriteCond % REQUEST_URI!/ category/final-subcategory/ RewriteCond % !-f RewriteRule ^(category/)./ category/final-subcategory/ [R=301, L] Here, we wish to reroute all under/ classification/ on the 3rd line other than if it is/ category/final-subcategory/ on the fourth line. We also have the “!-f” guideline on the 2nd line, ignoring any file like images, CSS, or JavaScript files.

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

Directory site Change

You can utilize the rule below if you did a category restructuring and wish to move everything 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 tell the server that it should remember 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 rerouted to/ new-directory/subdirectory/.

I used two guidelines: one case with no trailing slash at the end and the other one with a routing slash.

I could integrate them into one guideline using (/? |. *)$ RegExp at the end, however it would trigger problems and add 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 state 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://% /$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, you might threaten your website with replicate content problems due to the fact that search engines deal with URLs with “www” and “non-www” variations as various pages with the very same content.

Therefore, you need to guarantee you run the site just with one version you choose.

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

RewriteCond % HTTP_HOST ^ 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 given 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 rerouted to/ example-page/. You may pick to eliminate the slash rather of including then you will require the other rule 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 used redirects that nearly every site has.

The reword rule listed below can be utilized to require HTTPS on every website.

RewriteCond % HTTP_HOST ^ 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 guideline.

Redirect From Old Domain To New

This is also one of the most secondhand redirects when you choose to rebrand and need to alter your domain. The guideline below redirects 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” variation of URLs and another “non-www” because any page for historic reasons might have incoming links to both versions.

A lot of site owners utilize WordPress and might not require a.htaccess apply for redirects but use a plugin instead.

Dealing with redirects using plugins may be somewhat different from what we talked about above. You may need to read their documents to manage RegExp correctly for the particular plugin.

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

Redirect Finest 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 proper landing page.

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

If you have a lot of pages like this, you need to think about producing stunning 404 pages and engaging users to search additional or discover something besides what they were trying to find by displaying a search alternative.

It is strongly advised by Google that rerouted page material should be comparable 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 make sure to reroute users to the appropriate page of the mobile variation.

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 ought to 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 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 right away to/ new-page/.

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

According to John Mueller, search engines might not have the ability to recognize that kind of redirect properly. The very same is also true about JavaScript redirects.

4. Avoid Redirect Chains

This message shows when you have an incorrect regular expression setup and ends up in a boundless loop.

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

page 1 is redirected and chosen to redirect page 2 to page 1 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 produce an infinite loop and produce the error revealed above. Conclusion Understanding what

redirects are and which circumstance requires a particular status code is essential to


webpages correctly. It’s a core part of understanding SEO. Lots of circumstances require precise knowledge of redirects, such as migrating a site to a brand-new domain or developing a temporary holding page URL for a web page that will return under its normal URL. While a lot is possible with a plugin, plugins can be misused without effectively comprehending when and why to utilize a specific

sort of redirect. More Resources: Included Image: