URL Redirects For SEO: A Technical Guide

Posted by

Redirects for SEO should be used properly because they affect how sites are crawled and indexed by Google.

While the majority of people think about redirects as an internet detour indication, much more is occurring, and it’s remarkably enjoyable to find.

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

What Is A Redirect?

Site reroutes tell browsers and online search engine information about a URL and where to discover the web page.

A URL redirect includes code carried out 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:

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

When To Use Redirects

The main reasons to utilize redirects are:

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

For SEO functions, URL redirects are very important because they:

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

Redirects can be carried out on a group or domain-wide basis but often require to be set on a specific basis to prevent problems.

When utilizing RegEX for group reroutes, it can have unforeseen outcomes if your reasoning isn’t perfect!

Kinds of Redirects

There are three main kinds of redirects:

  • Meta Refresh redirects are set at the page level however are normally not suggested for SEO functions. There are two kinds of meta redirect: delayed which is seen as a short-lived redirect, and instant, which is seen as a permanent redirect.
  • Javascript redirects are likewise set on the customer side’s page and can cause SEO issues. Google has specified a preference for HTTP server-side redirects.
  • HTTP redirects are set server-side and the best technique for SEO functions– we covered in-depth below.

What Is A HTTP Reaction Status Code?

Browsers and online search engine crawlers like GoogleBot are called user representatives.

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

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

In the circumstance where a user agent like GoogleBot requests a URL, the server provides a reaction.

For instance, if the ask for a URL is successful, the server will provide an action code of 200, which implies the request for a URL succeeded.

So, when you think of a GoogleBot reaching a site and trying to crawl it, what’s occurring 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 various URL (due to the fact that it was moved), the server tells the user agent that the URL request is being redirected to a different URL.

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

The whole 3xx series of reaction codes interact much info that can optionally be acted upon by the user representative.

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

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

3XX Series Of Status Codes

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

There are an overall of 7 official 3xx action status codes.

These are the different kinds of redirects available for usage:

  • 300 Several Choices.
  • 301 Moved Completely.
  • 302 Found.
  • 303 See Other.
  • 304 Not Customized.
  • 305 Use 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 utilized. So, before using any redirect code other than 301 or 302, make certain that the designated user representative can analyze it.

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

For SEO, one must stick to using the 301 and 302 response codes unless there is a specific reason to use among the other codes.

301: Moved Permanently

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

The 301 redirect shows to a user agent that the URL (in some cases referred to as a target resource or simply resource) was altered to another area which it ought to utilize the brand-new URL for future requests.

As mentioned previously, there is more details also.

The 301 status code also suggests to the user representative:

  • Future requests for the URL need to be made with the new URL.
  • Whoever is making the request ought to update their links to the brand-new URL.
  • Subsequent requests 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 historic reasons, a user agent MAY change the request technique from POST to GET for the subsequent request. If this habits is undesirable, the 308 (Irreversible 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 new one.

Before making a change, you need to be careful when using a 301 redirect. The 301 redirects should only be used when the change to a brand-new URL is irreversible.

The 301 status code should not be utilized when the modification is momentary.

In addition, if you change your mind later on and go back to the old URL, the old URL may 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 permanent.

302: Found

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

The meaning of this reaction code is that the URL is briefly at a various URL, and it is recommended to utilize the old URL for future demands.

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

“Keep in mind: For historic reasons, a user representative MAY change the request technique from POST to GET for the subsequent request. If this habits is unwanted, the 307 (Momentary Redirect) status code can be utilized rather.”

The reference to “historical reasons” might describe old or buggy user representatives that may alter the demand method.

307: Temporary Redirect

A 307 redirect means the asked for URL is momentarily moved, and the user representative ought to use the original URL for future demands.

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

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

The Mozilla documents of the 307 status code explains it more plainly than the official documentation.

“The server sends this action to direct the client to get the asked for resource at another URI with very same method 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 technique used: if a POST was utilized in the very first demand, a POST must be utilized in the second demand.”

Besides the 307 status code requiring subsequent demands to be of the very same kind (POST or GET) which the 302 can go in any case, whatever else is the exact 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 via plugins if you are using WordPress.

In all instances, they have the very same syntax for writing redirect guidelines. They vary just with commands utilized in setup files. For instance, a redirect on Apache will look like this:

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

(You can read about symlinks here.)

On Nginx servers, it will appear like this:

rewrite ^/ oldfolder// newfolder/ permanent;

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

For example:

  • Servers status code of redirect: “301 ″ vs. “permanent.”
  • Action command: “RedirectMatch” vs. “reword.”

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

On Apache, guarantee that mod_rewrite and mod_alias modules (accountable for dealing with redirects) are enabled on your server.

Because the most extensively spread server type is Apache, here are examples for.htaccess apache files.

Ensure that the.htaccess file has these two lines above the redirect rules and put the guidelines below them:

Choices +FollowSymlinks RewriteEngine on

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

To comprehend the examples listed below, you may describe 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) remembers the match to be used when calling $1

How To Produce Redirects

How To Produce A Redirect For A Single URL

The most common and extensively utilized kind of redirect is when erasing pages or altering URLs.

For instance, 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 difference between the two methods is that the very first utilizes the Apache mod_rewrite module, and the 2nd usages mod_alias. It can be done using both approaches.

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

We could also utilize (. *), i.e., ^/ old-page(. *), however the problem is, if you have another page with a similar URL like/ old-page-other/, it will likewise be redirected when we just want to redirect/ 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 reroute in the list below kind:

Redirect 301/ old-page// new-page/

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

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

RewriteCond % !/ category/final-subcategory/ RewriteCond % REQUEST_FILENAME!-f RewriteRule ^(classification/)./ category/final-subcategory/ [R=301, L] Here, we want to reroute all under/ category/ on the 3rd line except if it is/ category/final-subcategory/ on the 4th line. We likewise have the “!-f” rule on the second line, disregarding any file like images, CSS, or JavaScript files.

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

Directory Change

You can utilize the guideline listed below if you did a classification restructuring and want to move whatever 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 utilized $1 in the target to tell the server that it should keep in mind whatever 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 redirected to/ new-directory/subdirectory/.

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

I could combine them into one rule utilizing (/? |. *)$ RegExp at the end, but it would cause problems and include a “//” slash to the end of the URL when the requested URL without any 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 site with the city name “Chicago” and want 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 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 duplicate content problems since online search engine treat URLs with “www” and “non-www” variations as different pages with the same material.

For that reason, you must guarantee you run the website only with one variation you select.

If you want 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 % HTTP_HOST ^ www.yourwebsite.com [NC] RewriteRule ^(. *)$ http://yourwebsite.com/$1 [L, R=301] Tracking slash is also part of canonicalization considering that URLs with a slash at the end or without are also dealt with 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 choose to remove the slash instead of including then you will need the other guideline below: RewriteCond % !-d RewriteRule ^(. *)/$/$1 [L, R=301]HTTP To HTTPS Redirect

After Google’s initiative to motivate website owners to utilize SSL, migrating to HTTPS is among the commonly used redirects that nearly every site has.

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

RewriteCond % HTTP_HOST ^ 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 variation reroute into one HTTPS redirect rule.

Redirect From Old Domain To New

This is also among the most pre-owned redirects when you decide to rebrand and require to alter your domain. The rule listed below redirects 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” due to the fact that any page for historical reasons might have inbound links to both variations.

Many site owners use WordPress and might not need a.htaccess file for redirects but utilize a plugin rather.

Handling redirects using plugins may be slightly different from what we discussed above. You might need to read their documentation to manage RegExp properly for the specific plugin.

From the existing ones, I would recommend a complimentary plugin called Redirection, which has lots of parameters to control redirect rules and lots of useful docs.

Reroute Finest Practices

1. Don’t Redirect All 404 Broken URLs To The Homepage

This case often takes place 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 too many pages like this, you should think about developing gorgeous 404 pages and engaging users to browse additional or discover something besides what they were looking for by showing a search option.

It is strongly recommended 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 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 must ensure to reroute users to the suitable page of the mobile version.

Correct: “example.com/sport/” to “m.example.com/sport/”
Incorrect: “example.com/sport/” to “m.example.com”

Also, you need to make sure that if one page is 404 on the desktop, it must also be 404 on mobile.

If you have no mobile variation for a page, you can prevent 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 revitalize tag like the example below:

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

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

According to John Mueller, online search engine might not be able to acknowledge that kind of redirect effectively. The same is also true about JavaScript reroutes.

4. Prevent 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 Typically, this takes place when you have a redirect chain. Let’s state you redirected page 1 to page 2 a very long time back. You may have forgotten that

page 1 is rerouted and decided to reroute page 2 to page 1 again. As a result, you will end up with a guideline like this: RewriteRule ^ page1/ page2 [R

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

redirects are and which situation requires a specific status code is essential to


webpages properly. It’s a core part of understanding SEO. Many scenarios need exact understanding of redirects, such as moving a website to a brand-new domain or producing a momentary holding page URL for a webpage that will return under its regular URL. While a lot is possible with a plugin, plugins can be misused without correctly understanding when and why to use a particular

sort of redirect. More Resources: Featured Image: