URL Reroutes For SEO: A Technical Guide

Posted by

Reroutes for SEO must be utilized correctly since they affect how websites are crawled and indexed by Google.

While the majority of people consider redirects as a web detour indication, much more is taking place, and it’s surprisingly enjoyable to discover.

Keep checking out for a thorough summary 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 web page.

A URL redirect includes code carried out to a specific URL, or a group of URLs so that the user (or search engine) is sent out to a different 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 Use Redirects

The primary reasons to utilize redirects are:

  • An individual page or entire domain has actually been moved (URL altered).
  • To enable the usage of URL shorteners or ‘quite URLs.’
  • Site migration (e.g., HTTP to HTTPS).

For SEO purposes, URL redirects are very important due to the fact that they:

  • Forward authority of any links pointing to a page that has moved or been erased.
  • Prevent 404 page not found mistakes (although sometimes it is much better to leave a 404).

Redirects can be carried out on a group or domain-wide basis but typically need to be set on a private basis to prevent problems.

When utilizing RegEX for group reroutes, it can have unexpected results 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 normally not suggested for SEO purposes. There are two kinds of meta redirect: delayed which is viewed as a short-term redirect, and immediate, which is seen as a long-term redirect.
  • Javascript redirects are likewise set on the customer side’s page and can trigger SEO issues. Google has mentioned a preference for HTTP server-side reroutes.
  • HTTP redirects are set server-side and the very best approach for SEO functions– we covered thorough listed below.

What Is A HTTP Response Status Code?

Browsers and search engine spiders like GoogleBot are called user agents.

When a user representative tries to access a webpage, what happens is that the user representative makes a demand, and the website server concerns a response.

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

In the situation where a user agent like GoogleBot requests a URL, the server offers a reaction.

For instance, if the ask for a URL is successful, the server will provide a reaction code of 200, which indicates the request for a URL was successful.

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

HTTP Redirects

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

If the URL exists at a different URL (because it was moved), the server tells the user agent that the URL request is being rerouted to a different URL.

The reaction code for a changed URL is normally in the form of a 301 or 302 action status code.

The entire 3xx series of reaction codes interact much info that can additionally be acted on 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 request for the brand-new URL rather.

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 simply the 2 status codes everybody is familiar with, the 301 and 302 response codes.

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

These are the different type of redirects offered for use:

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

Some of the above status codes have actually not been around as long and might not be used. So, prior to using any redirect code other than 301 or 302, be sure that the desired user agent can analyze it.

Since GoogleBot utilizes the current variation of Chrome (called a headless internet browser), it’s simple to examine if a status code works by inspecting if Chrome recognizes the status code with a web browser compatibility list.

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

301: Moved Permanently

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

The 301 redirect indicates to a user representative that the URL (often described as a target resource or just resource) was altered to another location and that it must use the brand-new URL for future requests.

As pointed out previously, there is more info as well.

The 301 status code likewise suggests to the user representative:

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

“Keep in mind: For historic factors, a user agent MAY change the demand approach from POST to GET for the subsequent demand. If this behavior is undesirable, the 308 (Permanent Redirect) status code can be utilized instead.”

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 beware when utilizing a 301 redirect. The 301 redirects should just be utilized when the change to a brand-new URL is permanent.

The 301 status code need to not be utilized when the change is momentary.

In addition, if you alter your mind later on and return to the old URL, the old URL might not rank any longer and might take some time to regain the rankings.

So, the main point to bear in mind is that a 301 status code will be used when the modification is permanent.

302: Found

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

The significance 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 likewise includes a technical caution associated to GET and Post:

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

The referral to “historic factors” might describe old or buggy user agents that may alter the demand method.

307: Temporary Redirect

A 307 redirect indicates the requested URL is briefly moved, and the user representative need to use the initial URL for future requests.

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

That implies if the user representative demands the page with a GET request, then the user representative should utilize a GET ask for the new momentary URL and can not utilize the POST demand.

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

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

This has the very same semantics as the 302 Found HTTP response code, with the exception that the user representative need to not change the HTTP method utilized: if a POST was utilized in the first demand, a POST should be utilized in the second request.”

Besides the 307 status code needing subsequent requests to be of the very same kind (POST or GET) and that 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 manage a redirect through server config files.htaccess on Apache, example.conf file on Nginx or via plugins if you are utilizing WordPress.

In all instances, they have the very same syntax for writing redirect guidelines. They differ just with commands utilized in setup files. For example, 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 used to tell 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. “reword.”

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

On Apache, guarantee that mod_rewrite and mod_alias modules (accountable for handling redirects) are allowed on your server.

Considering that the most widely spread out 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 guidelines listed below them:

Alternatives +FollowSymlinks RewriteEngine on

Read the official paperwork to learn more about the RewriteEngine.

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

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

How To Produce 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, say 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 2 approaches is that the very first uses the Apache mod_rewrite module, and the second uses mod_alias. It can be done using both approaches.

The routine expression “^” implies 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 might also 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 just want 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 reroute any variation of the page URL to a brand-new one. If we utilize redirect in the list below form:

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

Without routine expressions, all URLs with UTM query string, e.g.,/ old-page? utm_source=facebook.com (which prevails given that URLs are utilized 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 Other than

Let’s state we have a lot of URLs like/ category/old-subcategory -1/,/ category/old-subcategory -2/,/ category/final-subcategory/ and wish to merge 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 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, overlooking 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 site Change

You can utilize the guideline listed below if you did a classification restructuring and wish to move everything 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 whatever 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 2 rules: one case without any routing slash at the end and the other one with a routing slash.

I could combine them into one guideline using (/? |. *)$ RegExp at the end, but it would cause issues and add a “//” slash to the end of the URL when the asked for URL with no trailing slash has an inquiry string (i.e., “/ old-directory? utm_source=facebook” would be rerouted to “/ new-directory//? utm_source=facebook”).

Remove A Word From URL

Let’s state 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 rule would be:

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

If missing, you might endanger your website with replicate content problems since online search engine treat URLs with “www” and “non-www” versions as various pages with the same content.

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

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

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] Routing slash is also part of canonicalization given that URLs with a slash at the end or without are likewise dealt with differently. RewriteCond % !-f RewriteRule ^(. * [^/]$/$1/ [L, R=301] This will make sure the/ example-page is rerouted to/ example-page/. You might pick to eliminate the slash instead of including then you will require the other guideline listed below: RewriteCond % !-d RewriteRule ^(. *)/$/$1 [L, R=301]HTTP To HTTPS Redirect

After Google’s initiative to encourage website owners to utilize SSL, migrating to HTTPS is one of the commonly utilized redirects that practically every site has.

The reword rule below can be used to require HTTPS on every site.

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

Redirect From Old Domain To New

This is likewise one of the most secondhand redirects when you decide to rebrand and need to change your domain. The guideline 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 two cases: one with the “www” variation of URLs and another “non-www” due to the fact that any page for historical reasons may have inbound links to both versions.

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

Managing redirects using plugins may be a little different from what we discussed above. You may need to read their paperwork to deal with RegExp properly for the specific plugin.

From the existing ones, I would suggest a complimentary plugin called Redirection, which has lots of parameters to manage redirect guidelines and lots of helpful docs.

Reroute Best Practices

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

If you have too many pages like this, you should think about producing gorgeous 404 pages and engaging users to browse more or discover something other than what they were searching for by showing a search choice.

It is highly advised by Google that rerouted page material should be comparable 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 various URLs for desktop and mobile websites (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/”
Wrong: “example.com/sport/” to “m.example.com”

Likewise, you have to ensure that if one page is 404 on the desktop, it should also be 404 on mobile.

If you have no mobile version for a page, you can avoid redirecting to the mobile version and keep them on the desktop page.

3. How To Utilize Meta Refresh

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

If you insert this tag in/ old-page/, it will redirect the user instantly to/ new-page/.

Google does not prohibit this redirect, however it does not recommend using it.

According to John Mueller, search engines might not be able to recognize that type of redirect effectively. The exact same is also real about JavaScript reroutes.

4. Avoid Redirect Chains

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

Screenshot by author, December 2022 Generally, 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 chosen to reroute 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 create an unlimited loop and produce the mistake shown above. Conclusion Understanding what

redirects are and which scenario requires a particular status code is basic to


web pages appropriately. It’s a core part of understanding SEO. Lots of situations require precise understanding of redirects, such as moving a site to a new domain or producing a short-term holding page URL for a website that will return under its typical URL. While a lot is possible with a plugin, plugins can be misused without correctly comprehending when and why to utilize a specific

kind of redirect. More Resources: Included Image: