URL Redirects For SEO: A Technical Guide

Posted by

Reroutes for SEO needs to be used correctly due to the fact that they affect how websites are crawled and indexed by Google.

While many people think of redirects as a web detour sign, a lot more is happening, and it’s surprisingly enjoyable to discover.

Keep checking out for a detailed summary of redirects and the correct application for technical SEO.

What Is A Redirect?

Website reroutes inform internet browsers and online search engine info about a URL and where to find the website.

A URL redirect includes code executed to a particular URL, or a group of URLs so that the user (or search engine) is sent out to a various page to the actual URL that was input or clicked.

A redirect can be set as a:

  • Momentary redirect: 302, 303, 307, 308.
  • Permanent redirect: 301.

When To Utilize Redirects

The primary factors to utilize redirects are:

  • An individual page or whole domain has been moved (URL changed).
  • To permit the use of URL shorteners or ‘quite URLs.’
  • Website migration (e.g., HTTP to HTTPS).

For SEO functions, URL redirects are important since they:

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

Redirects can be executed 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 unexpected outcomes if your reasoning isn’t flawless!

Kinds of Redirects

There are 3 primary types of redirects:

  • Meta Refresh redirects are set at the page level however are normally not advised for SEO purposes. There are two types of meta redirect: delayed which is viewed as a short-lived redirect, and instant, which is viewed as a long-term redirect.
  • Javascript reroutes are also set on the client side’s page and can trigger SEO concerns. Google has actually mentioned a choice for HTTP server-side redirects.
  • HTTP redirects are set server-side and the best method for SEO functions– we covered thorough listed below.

What Is A HTTP Action Status Code?

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

When a user representative attempts to access a web page, what happens is that the user agent makes a demand, and the site server problems a reaction.

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

In the scenario where a user representative like GoogleBot demands a URL, the server gives an action.

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

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 action to request a URL.

If the URL exists at a various URL (since it was moved), the server informs the user representative that the URL request is being rerouted to a various URL.

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

The entire 3xx series of response codes interact much information that can additionally be acted on by the user representative.

An example of an action that the user agent can take is to conserve a cache of the 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 an internet road indication that states, “Go here, not there.”

3XX Series Of Status Codes

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

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

These are the different kinds of redirects available for usage:

  • 300 Multiple Choices.
  • 301 Moved Permanently.
  • 302 Found.
  • 303 See Other.
  • 304 Not Modified.
  • 305 Usage Proxy.
  • 306 (Unused).
  • 307 Short-lived Redirect.
  • 308 Long-term Redirect.

A few of the above status codes have not been around as long and may not be used. So, prior to utilizing any redirect code other than 301 or 302, be sure that the desired user agent can translate it.

Because GoogleBot uses the most recent version of Chrome (called a headless browser), it’s easy to examine if a status code works by inspecting if Chrome recognizes the status code with an internet browser compatibility list.

For SEO, one need to stay with utilizing the 301 and 302 response codes unless there is a specific reason to use one of the other codes.

301: Moved Completely

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

The 301 redirect suggests to a user agent that the URL (sometimes described as a target resource or just resource) was altered to another location and that it ought to utilize the brand-new URL for future requests.

As pointed out earlier, there is more info too.

The 301 status code also suggests to the user agent:

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

That last point is a technical problem. 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 behavior is undesirable, the 308 (Long-term Redirect) status code can be utilized instead.”

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

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

The 301 status code should not be used when the change is temporary.

Furthermore, if you alter your mind later on and go back to the old URL, the old URL might not rank any longer and might require time to regain the rankings.

So, the main point to remember is that a 301 status code will be utilized 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 momentarily changed.

The meaning of this response 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 comes with a technical caveat related to GET and Post:

“Note: For historic reasons, a user representative MAY alter the demand approach from POST to GET for the subsequent request. If this behavior is undesirable, the 307 (Momentary Redirect) status code can be utilized rather.”

The reference to “historic factors” may refer to old or buggy user agents that may alter the demand technique.

307: Temporary Redirect

A 307 redirect implies the asked for URL is temporarily moved, and the user representative must use the initial URL for future requests.

The only distinction between a 302 and a 307 status code is that a user agent should ask for the brand-new URL with the same HTTP demand utilized to request the initial URL.

That implies if the user representative requests the page with a GET demand, then the user agent need to utilize a GET ask for the new temporary URL and can not utilize the POST demand.

The Mozilla paperwork of the 307 status code discusses it more clearly than the official documentation.

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

This has the very same semantics as the 302 Found HTTP reaction code, with the exception that the user representative need to not change the HTTP approach utilized: if a POST was used in the first demand, a POST should be utilized in the 2nd demand.”

Aside from the 307 status code requiring subsequent demands to be of the exact same kind (POST or GET) and that the 302 can go either way, everything else is the very same 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 by means of plugins if you are utilizing WordPress.

In all circumstances, they have the very same syntax for writing redirect rules. They vary only with commands utilized in setup files. For instance, 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 look like this:

rewrite ^/ oldfolder// newfolder/ permanent;

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

For instance:

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

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

On Apache, make sure that mod_rewrite and mod_alias modules (responsible for handling redirects) are enabled on your server.

Because the most widely 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:

Options +FollowSymlinks RewriteEngine on

Read the official documentation to find out more about the RewriteEngine.

To comprehend the examples listed below, you may describe the table listed below on RegExp fundamentals.

* zero or more times
+ Several times
. any single character
? Zero or one time
^ Start of the string
$ End of the string
| b OR operadn” |” a or b
(z) remembers the match to be utilized when calling $1

How To Develop Redirects

How To Develop A Redirect For A Single URL

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

For example, say you altered 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 distinction in between the 2 methods is that the very first utilizes the Apache mod_rewrite module, and the 2nd uses mod_alias. It can be done using both techniques.

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

We could likewise use (. *), 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 wish 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 reroute any variation of the page URL to a new one. If we utilize redirect in the following kind:

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

Without routine expressions, all URLs with UTM query string, e.g.,/ old-page? utm_source=facebook.com (which prevails because URLs are used to be shared over a social network), would wind 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 want to merge all subcategories into/ category/final-subcategory/. We need the “all except” guideline here.

RewriteCond % !/ category/final-subcategory/ RewriteCond % REQUEST_FILENAME!-f RewriteRule ^(classification/)./ 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 4th line. We likewise have the “!-f” guideline on the 2nd line, disregarding any file like images, CSS, or JavaScript files.

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

Directory site Modification

You can utilize the rule below if you did a classification restructuring and wish 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 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 rule utilizing (/? |. *)$ RegExp at the end, however it would trigger problems and include a “//” slash to the end of the URL when the requested URL without any tracking slash has a question string (i.e., “/ old-directory? utm_source=facebook” would be rerouted to “/ new-directory//? utm_source=facebook”).

Remove 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 type 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 fundamental part of SEO.

If missing, you may endanger your website with duplicate content problems due to the fact that online search engine treat URLs with “www” and “non-www” variations as different pages with the same content.

For that reason, you need to guarantee you run the website just with one variation you select.

If you want to run your website with the “www” variation, 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 likewise part of canonicalization given that URLs with a slash at the end or without are also treated differently. RewriteCond % !-f RewriteRule ^(. * [^/]$/$1/ [L, R=301] This will make sure the/ example-page is redirected to/ example-page/. You might choose to eliminate the slash rather 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 initiative to encourage site owners to utilize SSL, moving to HTTPS is one of the commonly utilized redirects that nearly every website has.

The rewrite rule below can be utilized 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 reroute into one HTTPS redirect rule.

Redirect From Old Domain To New

This is also among the most used redirects when you decide to rebrand and require to change your domain. The rule listed below reroutes 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 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.

A lot of website owners utilize WordPress and might not require a.htaccess declare redirects but use a plugin rather.

Handling redirects using plugins may be a little various from what we went over above. You may need to read their paperwork to handle RegExp correctly for the specific plugin.

From the existing ones, I would advise a free plugin called Redirection, which has numerous parameters to manage redirect guidelines and lots of beneficial docs.

Reroute Finest Practices

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

This case often occurs 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 treated as 404s.

If you have a lot of pages like this, you must consider creating stunning 404 pages and engaging users to browse additional or discover something aside from what they were searching for by displaying a search alternative.

It is strongly suggested 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 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 ought to make sure to redirect 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 guarantee that if one page is 404 on the desktop, it must 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 utilizing a meta refresh tag like the example below:

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

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

According to John Mueller, online search engine might not have the ability to recognize that type of redirect effectively. The exact same is likewise real about JavaScript redirects.

4. Avoid Redirect Chains

This message displays when you have an incorrect regular expression setup and ends up in an unlimited loop.

Screenshot by author, December 2022 Generally, this happens when you have a redirect chain. Let’s state you redirected page 1 to page 2 a long period of time earlier. You may have forgotten that

page 1 is rerouted and chosen to reroute page 2 to page 1 again. As a result, 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 develop a limitless loop and produce the error shown above. Conclusion Knowing what

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


web pages correctly. It’s a core part of understanding SEO. Numerous circumstances require accurate knowledge of redirects, such as migrating a site to a new domain or developing a temporary holding page URL for a website that will return under its typical URL. While so much is possible with a plugin, plugins can be misused without properly understanding when and why to utilize a particular

kind of redirect. More Resources: Included Image: