URL Reroutes For SEO: A Technical Guide

Posted by

Redirects for SEO needs to be used correctly because they impact how websites are crawled and indexed by Google.

While most people consider redirects as an internet detour sign, much more is taking place, and it’s remarkably enjoyable to find.

Keep checking out for an extensive summary of redirects and the appropriate application for technical SEO.

What Is A Redirect?

Site reroutes tell web browsers and search engines information 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 online 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-lived redirect: 302, 303, 307, 308.
  • Permanent redirect: 301.

When To Use Redirects

The main reasons to utilize redirects are:

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

For SEO purposes, URL redirects are necessary 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 discovered mistakes (although in some cases it is better to leave a 404).

Redirects can be executed on a group or domain-wide basis however often require to be set on an individual basis to avoid concerns.

When utilizing RegEX for group redirects, it can have unexpected outcomes if your reasoning isn’t flawless!

Kinds of Redirects

There are three primary kinds of redirects:

  • Meta Refresh redirects are set at the page level however are usually not suggested for SEO purposes. There are 2 kinds of meta redirect: delayed which is viewed as a short-lived redirect, and instant, which is seen as an irreversible redirect.
  • Javascript redirects are likewise set on the customer side’s page and can cause SEO issues. Google has actually stated a preference for HTTP server-side redirects.
  • HTTP redirects are set server-side and the best technique for SEO functions– we covered extensive below.

What Is A HTTP Response Status Code?

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

When a user representative attempts to access a web page, what happens is that the user representative makes a request, and the site server problems an action.

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

In the scenario where a user agent like GoogleBot requests a URL, the server offers an action.

For example, if the ask for a URL is successful, the server will offer a response code of 200, which suggests the request for a URL succeeded.

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

HTTP Reroutes

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 informs the user representative that the URL request is being rerouted to a various URL.

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

The entire 3xx series of action codes interact much information that can optionally be acted upon by the user agent.

An example of an action that the user agent can take is to save a cache of the new URL so that the next time the old URL is requested, it will request for the brand-new URL instead.

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

3XX Series Of Status Codes

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

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

These are the different kinds of redirects offered for use:

  • 300 Numerous Choices.
  • 301 Moved Permanently.
  • 302 Found.
  • 303 See Other.
  • 304 Not Modified.
  • 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 designated user representative can interpret it.

Because GoogleBot utilizes the most recent variation of Chrome (called a headless browser), it’s simple to examine if a status code works by checking if Chrome recognizes the status code with a web browser compatibility list.

For SEO, one need to stay with utilizing the 301 and 302 reaction codes unless there is a particular factor to use among the other codes.

301: Moved Completely

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

The 301 redirect shows to a user representative that the URL (often described as a target resource or simply resource) was changed to another area which it ought to use the new URL for future requests.

As discussed previously, there is more details also.

The 301 status code also recommends to the user representative:

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

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

“Note: For historical reasons, a user agent MAY alter the request approach from POST to GET for the subsequent request. If this habits is unwanted, the 308 (Long-term Redirect) status code can be used instead.”

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

Before making a change, you need to be careful when using a 301 redirect. The 301 redirects need to just be utilized when the change to a brand-new URL is permanent.

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

Furthermore, if you alter your mind later on and return to the old URL, the old URL may not rank anymore and may require time to restore the rankings.

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

302: Found

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

The significance of this action code is that the URL is momentarily at a various URL, and it is suggested to utilize the old URL for future demands.

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

“Note: For historic reasons, a user representative MAY change the request method from POST to GET for the subsequent request. If this behavior is unwanted, the 307 (Temporary Redirect) status code can be utilized instead.”

The reference to “historic reasons” may refer to old or buggy user agents that might change the request approach.

307: Temporary Redirect

A 307 redirect indicates the requested URL is briefly moved, and the user agent must use the initial URL for future requests.

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

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

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

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

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

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

302 Vs. 307

You may manage a redirect via server config files.htaccess on Apache, example.conf file on Nginx or through plugins if you are utilizing WordPress.

In all circumstances, they have the same syntax for writing redirect guidelines. They differ only with commands used in configuration files. For example, a redirect on Apache will look like this:

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

(You can check out symlinks here.)

On Nginx servers, it will appear like this:

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

The commands used to inform 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. “reword.”

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

On Apache, guarantee that mod_rewrite and mod_alias modules (responsible for managing redirects) are made it possible for on your server.

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

Make certain that the.htaccess file has these two lines above the redirect rules and put the rules listed below them:

Choices +FollowSymlinks RewriteEngine on

Read the official paperwork to get more information about the RewriteEngine.

To understand the examples listed below, you may refer to the table listed 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 used when calling $1

How To Create Redirects

How To Produce A Redirect For A Single URL

The most typical and extensively utilized 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 in between the 2 methods is that the 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 begin with “/ old-page” while (/? |/. *)$ indicates that anything that follows “/ old-page/” with a slash “/” or without a precise match must be rerouted to/ new-page/.

We could likewise utilize (. *), i.e., ^/ old-page(. *), however the problem is, if you have another page with a comparable 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 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 following type:

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

Without routine expressions, all URLs with UTM inquiry string, e.g.,/ old-page? utm_source=facebook.com (which prevails considering that URLs are used to be shared over a social network), would end up as 404s.

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

Redirect All Except

Let’s state we have a lot 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 require the “all other than” guideline here.

RewriteCond % !/ category/final-subcategory/ RewriteCond % !-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 also have the “!-f” rule on the 2nd line, overlooking any file like images, CSS, or JavaScript files.

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

Directory Change

You can utilize the rule below if you did a category restructuring and want to move whatever from the old directory site 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 inform the server that it ought to 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 utilized two guidelines: one case with no routing slash at the end and the other one with a trailing slash.

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

Remove A Word From URL

Let’s state you have 100 URLs on your site with the city name “Chicago” and want to eliminate 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 vital part of SEO.

If missing, you might endanger your website with duplicate content concerns because online search engine deal with URLs with “www” and “non-www” versions as various pages with the same material.

For that reason, you need to guarantee you run the site just with one variation you choose.

If you want to run your site with the “www” version, use 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] Trailing slash is also part of canonicalization because URLs with a slash at the end or without are also treated differently. RewriteCond % !-f RewriteRule ^(. * [^/]$/$1/ [L, R=301] This will ensure the/ example-page is redirected to/ example-page/. You may select to eliminate the slash instead 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 effort to motivate website owners to utilize SSL, migrating to HTTPS is among the frequently utilized redirects that practically every site has.

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

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 reroute into one HTTPS redirect rule.

Redirect From Old Domain To New

This is likewise among the most secondhand redirects when you decide to rebrand and require 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 utilizes two cases: one with the “www” version of URLs and another “non-www” because any page for historical reasons might have inbound links to both variations.

Most website owners use WordPress and might not require a.htaccess apply for redirects but utilize a plugin rather.

Dealing with redirects utilizing plugins might be slightly different from what we went over above. You might require to read their documentation to manage RegExp properly for the particular plugin.

From the existing ones, I would advise a free plugin called Redirection, which has many criteria to manage redirect guidelines and many useful docs.

Redirect Finest Practices

1. Do not Redirect All 404 Broken URLs To The Homepage

This case often occurs when you are too lazy to investigate 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 too many pages like this, you need to consider developing stunning 404 pages and engaging users to browse additional or discover something other than what they were trying to find by displaying a search alternative.

It is highly suggested by Google that redirected page content need to 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 various URLs for desktop and mobile websites (i.e., “example.com” for desktop and “m.example.com” for mobile), you need to ensure to reroute users to the proper page of the mobile variation.

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 ought to likewise 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 below:

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

Google does not restrict this redirect, however it does not suggest utilizing it.

According to John Mueller, online search engine might not have the ability to acknowledge that type of redirect properly. The very same is also real about JavaScript redirects.

4. Avoid Redirect Chains

This message shows when you have a wrong routine expression setup and winds up in an unlimited loop.

Screenshot by author, December 2022 Typically, this happens when you have a redirect chain. Let’s state you rerouted page 1 to page 2 a very long time back. You may have forgotten that

page 1 is rerouted and chosen to reroute page 2 to page 1 again. As an outcome, 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 an unlimited loop and produce the mistake revealed above. Conclusion Understanding what

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


webpages effectively. It’s a core part of understanding SEO. Lots of situations need accurate understanding of redirects, such as moving a site to a new domain or producing a temporary holding page URL for a website that will return under its regular URL. While a lot is possible with a plugin, plugins can be misused without appropriately understanding when and why to utilize a particular

sort of redirect. More Resources: Featured Image: