URL Redirects For SEO: A Technical Guide

Posted by

Reroutes for SEO should be utilized properly 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, a lot more is happening, and it’s remarkably pleasurable to discover.

Keep reading for an extensive overview of redirects and the proper application for technical SEO.

What Is A Redirect?

Site redirects inform web browsers and search engines details about a URL and where to find the web page.

A URL redirect involves code carried out to a specific URL, or a group of URLs so that the user (or online 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.
  • Permanent redirect: 301.

When To Utilize Redirects

The primary factors to utilize redirects are:

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

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

  • Forward authority of any links indicating a page that has 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 however typically need to be set on an individual basis to prevent concerns.

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

Kinds of Redirects

There are 3 primary kinds of redirects:

  • Meta Refresh redirects are set at the page level however are normally not suggested for SEO functions. There are 2 kinds of meta redirect: delayed which is seen as a temporary redirect, and instant, which is viewed as an irreversible redirect.
  • Javascript reroutes are likewise set on the client side’s page and can cause SEO problems. Google has actually mentioned a choice for HTTP server-side redirects.
  • HTTP redirects are set server-side and the very best method for SEO purposes– we covered in-depth listed below.

What Is A HTTP Action Status Code?

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

When a user agent attempts to access a webpage, what takes place is that the user representative makes a demand, and the website server concerns an action.

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

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

For instance, if the request for a URL is successful, the server will supply an action code of 200, which suggests the request for a URL achieved success.

So, when you think of a GoogleBot reaching a website and attempting to crawl it, what’s occurring is a series of requests and actions.

HTTP Redirects

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

If the URL exists at a various URL (because it was moved), the server informs the user agent that the URL demand is being redirected to a different URL.

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

The entire 3xx series of action codes communicate much details that can additionally 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 ask for the new URL instead.

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

3XX Series Of Status Codes

Redirects are more than just the 2 status codes everyone recognizes with, the 301 and 302 action codes.

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

These are the different sort of redirects offered for usage:

  • 300 Several Options.
  • 301 Moved Completely.
  • 302 Found.
  • 303 See Other.
  • 304 Not Customized.
  • 305 Use Proxy.
  • 306 (Unused).
  • 307 Short-lived Redirect.
  • 308 Long-term Redirect.

Some of the above status codes have actually not been around as long and might not be utilized. So, prior to using any redirect code aside from 301 or 302, make certain that the intended user agent can interpret it.

Because GoogleBot uses the latest variation of Chrome (called a headless browser), it’s simple to check if a status code is compatible by checking if Chrome acknowledges the status code with a web browser compatibility list.

For SEO, one need to stick to utilizing the 301 and 302 reaction codes unless there is a specific reason to utilize one of the other codes.

301: Moved Permanently

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

The 301 redirect indicates to a user agent that the URL (often described as a target resource or merely resource) was changed to another area and that it must use the new URL for future demands.

As discussed earlier, there is more info also.

The 301 status code likewise suggests to the user representative:

  • Future requests for the URL ought to be made with the brand-new URL.
  • Whoever is making the request should 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 main standards for the 301 status code:

“Note: For historical reasons, a user agent MAY change the demand method from POST to GET for the subsequent request. If this habits is undesirable, the 308 (Permanent Redirect) status code can be utilized rather.”

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

Prior to making a change, you should be careful when utilizing a 301 redirect. The 301 redirects need to just be used when the modification to a brand-new URL is long-term.

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

Furthermore, if you change your mind later and return to the old URL, the old URL may not rank any longer and might require time to regain the rankings.

So, the main thing to keep in mind is that a 301 status code will be used when the change is long-term.

302: Found

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

The meaning of this reaction code is that the URL is temporarily at a different URL, and it is recommended to use the old URL for future requests.

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

“Note: For historic factors, a user agent MAY change the demand technique from POST to GET for the subsequent demand. If this habits is unwanted, the 307 (Short-lived Redirect) status code can be utilized instead.”

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

307: Temporary Redirect

A 307 redirect indicates the requested URL is briefly moved, and the user representative ought to utilize the original URL for future requests.

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

That implies if the user agent demands the page with a GET request, then the user agent should utilize a GET ask for the new short-term URL and can not use the POST demand.

The Mozilla documentation of the 307 status code discusses 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 exact same method that was utilized in the prior demand.

This has the exact same semantics as the 302 Found HTTP reaction code, with the exception that the user agent must not change the HTTP approach used: if a POST was used in the first demand, a POST must be utilized in the 2nd request.”

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

302 Vs. 307

You might manage a redirect through server config files.htaccess on Apache, example.conf file on Nginx or by means of plugins if you are using WordPress.

In all instances, 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 appear like this:

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

(You can check out symlinks here.)

On Nginx servers, it will look like this:

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

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

For example:

  • Servers status code of redirect: “301 ″ vs. “irreversible.”
  • 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 allowed on your server.

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

Choices +FollowSymlinks RewriteEngine on

Read the official documents for more information about the RewriteEngine.

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

* absolutely 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 common and extensively used kind of redirect is when deleting pages or altering URLs.

For instance, 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 2 approaches is that the very first utilizes the Apache mod_rewrite module, and the 2nd uses mod_alias. It can be done utilizing both approaches.

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

We might also utilize (. *), i.e., ^/ old-page(. *), but the problem is, if you have another page with a similar URL like/ old-page-other/, it will likewise be redirected when we only wish to reroute/ 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 kind:

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 given that URLs are utilized to be shared over a social media network), would wind up as 404s.

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

Redirect All Other than

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 require the “all other than” rule here.

RewriteCond % REQUEST_URI!/ category/final-subcategory/ RewriteCond % REQUEST_FILENAME!-f RewriteRule ^(category/)./ category/final-subcategory/ [R=301, L] Here, we wish to redirect all under/ classification/ on the 3rd line other than if it is/ category/final-subcategory/ on the fourth line. We also have the “!-f” rule 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 also be rerouted to “/ final-subcategory/” and trigger an image break.

Directory Modification

You can use the rule below if you did a category 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 inform the server that it ought to 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 rerouted to/ new-directory/subdirectory/.

I utilized two guidelines: one case without any tracking slash at the end and the other one with a trailing slash.

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

Eliminate A Word From URL

Let’s say 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://% 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://% /$1/$2 [NC, R=301, L] Set A Canonical URL

Having canonical URLs is the most important part of SEO.

If missing out on, you might threaten your site with replicate content concerns because search engines treat URLs with “www” and “non-www” versions as different pages with the exact same material.

Therefore, you should ensure you run the website just with one variation you select.

If you want to run your website 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” variation: RewriteCond % HTTP_HOST ^ www.yourwebsite.com [NC] RewriteRule ^(. *)$ http://yourwebsite.com/$1 [L, R=301] Routing slash is also part of canonicalization because URLs with a slash at the end or without are also dealt with differently. RewriteCond % !-f RewriteRule ^(. * [^/]$/$1/ [L, R=301] This will make certain the/ example-page is rerouted to/ example-page/. You might choose to remove the slash instead of adding then you will need the other rule listed below: RewriteCond % !-d RewriteRule ^(. *)/$/$1 [L, R=301]HTTP To HTTPS Redirect

After Google’s effort to motivate site owners to utilize SSL, moving to HTTPS is among the frequently utilized redirects that nearly every website has.

The rewrite rule below can be utilized to require 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] Utilizing this, you can integrate a www or non-www version reroute into one HTTPS redirect guideline.

Redirect From Old Domain To New

This is also among the most secondhand redirects when you choose to rebrand and require to alter your domain. The rule below reroutes old-domain. com to new-domain. com.

RewriteCond % HTTP_HOST ^ old-domain. com$ [OR] RewriteCond % ^ www.old-domain.com$ RewriteRule (. *)$ http://www.new-domain.com/$1 [R=301, L] It utilizes 2 cases: one with the “www” variation of URLs and another “non-www” since any page for historic factors might have incoming links to both variations.

Most site owners use WordPress and might not need a.htaccess declare redirects however use a plugin rather.

Dealing with redirects utilizing plugins might be a little different from what we went over above. You may require to read their documents to handle RegExp properly for the particular plugin.

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

Redirect Best Practices

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

This case often takes place when you are too lazy to investigate 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 must think about producing beautiful 404 pages and engaging users to search further or discover something besides what they were searching for by showing a search option.

It is highly advised by Google that redirected page content ought to 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 should make sure to reroute users to the appropriate 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 should likewise 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 refresh tag like the example listed below:

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

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

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

4. Avoid Redirect Chains

This message displays when you have a wrong routine expression setup and ends up in an unlimited 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 long time earlier. You might have forgotten that

page 1 is redirected and decided to reroute 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 unlimited loop and produce the mistake shown above. Conclusion Knowing what

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


web pages properly. It’s a core part of understanding SEO. Lots of circumstances need exact understanding of redirects, such as moving a website to a brand-new domain or creating 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 correctly comprehending when and why to utilize a specific

sort of redirect. More Resources: Featured Image: