URL Redirects For SEO: A Technical Guide

Posted by

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

While many people consider redirects as a web detour indication, far more is occurring, and it’s remarkably enjoyable to find.

Keep checking out for a detailed introduction of redirects and the proper application for technical SEO.

What Is A Redirect?

Website redirects inform browsers and online search engine information about a URL and where to discover 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-term redirect: 302, 303, 307, 308.
  • Long-term redirect: 301.

When To Utilize Redirects

The primary factors to utilize redirects are:

  • A private 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 purposes, URL redirects are essential due to the fact that they:

  • Forward authority of any links indicating a page that has moved or been erased.
  • Prevent 404 page not discovered mistakes (although often it is better to leave a 404).

Redirects can be implemented on a group or domain-wide basis however typically require to be set on a private basis to prevent problems.

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

Types Of Redirects

There are three primary types of redirects:

  • Meta Refresh redirects are set at the page level however are typically not advised for SEO functions. There are 2 types of meta redirect: postponed which is seen as a momentary redirect, and immediate, which is seen as a long-term redirect.
  • Javascript reroutes are also set on the client side’s page and can trigger SEO issues. Google has specified a preference for HTTP server-side redirects.
  • HTTP redirects are set server-side and the very best method for SEO purposes– we covered extensive listed below.

What Is A HTTP Action Status Code?

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

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

The response 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 gives an action.

For instance, if the request for a URL succeeds, the server will offer a response code of 200, which indicates the ask for a URL achieved success.

So, when you think about a GoogleBot reaching a website and attempting to crawl it, what’s taking place is a series of demands and reactions.

HTTP Reroutes

An HTTP redirect is a server reaction 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 request is being redirected to a different URL.

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

The whole 3xx series of response codes interact much information that can additionally be acted upon by the user agent.

An example of an action that the user representative can take is to conserve a cache of the brand-new URL so that the next time the old URL is requested, it will ask for the new URL rather.

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 simply the two status codes everyone recognizes with, the 301 and 302 response codes.

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

These are the different sort of redirects available for usage:

  • 300 Numerous Options.
  • 301 Moved Completely.
  • 302 Found.
  • 303 See Other.
  • 304 Not Modified.
  • 305 Usage Proxy.
  • 306 (Unused).
  • 307 Short-lived Redirect.
  • 308 Irreversible Redirect.

A few of the above status codes have not been around as long and might not be utilized. So, before utilizing any redirect code other than 301 or 302, make certain that the designated user representative can interpret it.

Because GoogleBot utilizes the most recent version of Chrome (called a headless web browser), it’s simple to examine if a status code is compatible by examining if Chrome acknowledges the status code with an internet browser compatibility list.

For SEO, one need to stay with using the 301 and 302 reaction codes unless there is a specific factor to utilize one of the other codes.

301: Moved Completely

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

The 301 redirect shows to a user representative that the URL (in some cases described as a target resource or just resource) was changed to another location and that it must use the brand-new URL for future demands.

As mentioned previously, there is more information also.

The 301 status code likewise recommends to the user agent:

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

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

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

The 301 status code must not be used when the modification is short-lived.

In addition, if you change your mind later on and return to the old URL, the old URL might not rank anymore and may take some time to restore the rankings.

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

302: Found

The main thing to understand about the 302 status code is that it works for scenarios where a URL is momentarily changed.

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 comes with a technical caveat associated to GET and Post:

“Keep in mind: For historical factors, a user representative MAY change the demand approach from POST to GET for the subsequent demand. If this behavior is undesired, the 307 (Temporary Redirect) status code can be used rather.”

The referral to “historical factors” may refer to old or buggy user representatives that may change the request approach.

307: Temporary Redirect

A 307 redirect indicates the requested URL is momentarily moved, and the user agent ought 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 must request the brand-new URL with the same HTTP request used to request the original URL.

That suggests if the user agent requests the page with a GET request, then the user representative should utilize a GET request for the brand-new short-term URL and can not utilize the POST demand.

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

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

This has the very same semantics as the 302 Found HTTP action code, with the exception that the user agent must not alter the HTTP method used: if a POST was used in the very first request, a POST needs to be utilized in the second 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 in any case, whatever else is the same between the 302 and the 307 status codes.

302 Vs. 307

You might handle a redirect via 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 composing redirect guidelines. They differ only with commands utilized in configuration files. For example, a redirect on Apache will appear 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/ 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. “irreversible.”
  • Action command: “RedirectMatch” vs. “rewrite.”

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

On Apache, ensure that mod_rewrite and mod_alias modules (accountable for managing redirects) are enabled on your server.

Because the most commonly 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 guidelines and put the rules below them:

Options +FollowSymlinks RewriteEngine on

Read the main documents to read more about the RewriteEngine.

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

* zero or more times
+ Several 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 used when calling $1

How To Create Redirects

How To Create A Redirect For A Single URL

The most typical and widely utilized type of redirect is when deleting 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 between the two approaches is that the very first uses the Apache mod_rewrite module, and the second usages mod_alias. It can be done using both approaches.

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

We could also 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 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 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 prevails since URLs are utilized to be shared over a social media 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 bunch 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 except” guideline here.

RewriteCond % REQUEST_URI!/ category/final-subcategory/ RewriteCond % !-f RewriteRule ^(category/)./ category/final-subcategory/ [R=301, L] Here, we want to redirect all under/ category/ 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, neglecting any file like images, CSS, or JavaScript files.

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

Directory Modification

You can use the rule below if you did a classification restructuring and wish to move everything from the old directory site 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 inform the server that it should remember whatever in the URL that follows/ old-directory/ (i.e.,/ old-directory/subdirectory/) and pass it (i.e., “/ subdirectory/”) onto the location. As a result, it will be redirected to/ new-directory/subdirectory/.

I utilized 2 rules: one case with no tracking 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 trigger problems and add a “//” slash to the end of the URL when the requested URL with no tracking slash has an inquiry 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 site 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://% SERVER_NAME/$1-$2 [NC, R=301, L] If the example URL is 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 out on, you might endanger your website with replicate content concerns due to the fact that search engines deal with URLs with “www” and “non-www” versions as different pages with the same material.

Therefore, you should guarantee you run the website just with one version you choose.

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

RewriteCond % HTTP_HOST ^ yourwebsite.com [NC] RewriteRule ^(. *)$ http://www.yourwebsite.com/$1 [L, R=301] For a “non-www” version: RewriteCond % HTTP_HOST ^ www.yourwebsite.com [NC] RewriteRule ^(. *)$ http://yourwebsite.com/$1 [L, R=301] Tracking slash is also 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 certain the/ example-page is redirected to/ example-page/. You may pick to remove the slash instead of including 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, moving to HTTPS is among the typically used redirects that almost every website has.

The reword rule listed 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] Utilizing 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 one of the most secondhand redirects when you decide to rebrand and require to alter your domain. The rule 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 uses two cases: one with the “www” variation of URLs and another “non-www” because any page for historic factors may have incoming links to both variations.

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

Managing redirects using plugins might be slightly different from what we went over above. You may need to read their documents to deal with RegExp correctly for the specific plugin.

From the existing ones, I would suggest a totally free plugin called Redirection, which has numerous specifications to manage redirect guidelines and many beneficial docs.

Reroute Best Practices

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

This case typically happens 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 should think about creating lovely 404 pages and engaging users to search more or find something aside from what they were looking for by displaying a search option.

It is highly advised by Google that rerouted page material must 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 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 redirect 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”

Also, you have to guarantee that if one page is 404 on the desktop, it needs to likewise be 404 on mobile.

If you have no mobile version for a page, you can avoid redirecting 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 refresh tag like the example listed below:

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

Google does not prohibit this redirect, however it doesn’t suggest using it.

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

4. Prevent Redirect Chains

This message displays when you have a wrong routine expression setup and winds up in a boundless loop.

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

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

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


webpages effectively. It’s a core part of comprehending SEO. Lots of circumstances require exact understanding of redirects, such as migrating a website to a new domain or creating 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 properly understanding when and why to use a specific

type of redirect. More Resources: Featured Image: