URL Reroutes For SEO: A Technical Guide

Posted by

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

While most people think about redirects as a web detour indication, much more is happening, and it’s surprisingly pleasurable to find.

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

What Is A Redirect?

Site redirects inform browsers and online search engine info about a URL and where to discover the web page.

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

A redirect can be set as a:

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

When To Use Redirects

The primary factors to use redirects are:

  • An individual 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 functions, URL redirects are important since they:

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

Redirects can be carried out on a group or domain-wide basis however often need to be set on a private basis to avoid problems.

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

Types Of Redirects

There are 3 main kinds of redirects:

  • Meta Refresh redirects are set at the page level however are normally not recommended for SEO functions. There are 2 kinds of meta redirect: postponed which is viewed as a momentary 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 problems. Google has actually stated a preference for HTTP server-side reroutes.
  • HTTP redirects are set server-side and the best method for SEO functions– we covered extensive 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 tries to access a webpage, what happens is that the user representative makes a demand, and the site server issues an action.

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

In the situation where a user representative like GoogleBot demands a URL, the server provides an action.

For example, if the ask for a URL succeeds, the server will supply an action code of 200, which suggests the ask for a URL succeeded.

So, when you think about a GoogleBot reaching a website and trying to crawl it, what’s happening is a series of requests and responses.

HTTP Reroutes

An HTTP redirect is a server response to request a URL.

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

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

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

An example of an action that the user representative can take is to save 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 sign that says, “Go here, not there.”

3XX Series Of Status Codes

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

There are an overall of seven official 3xx reaction status codes.

These are the various kinds of redirects readily available for use:

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

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

Due to the fact that GoogleBot uses the latest variation of Chrome (called a headless internet browser), it’s easy to examine if a status code works by inspecting if Chrome recognizes the status code with a browser compatibility list.

For SEO, one should stay with utilizing the 301 and 302 response codes unless there is a particular reason to utilize among the other codes.

301: Moved Permanently

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

The 301 redirect indicates to a user agent that the URL (in some cases described as a target resource or simply resource) was altered to another location which it need to use the brand-new URL for future demands.

As discussed earlier, there is more information too.

The 301 status code likewise recommends to the user representative:

  • Future requests for the URL need to be made with the new URL.
  • Whoever is making the demand ought to update their links to the brand-new URL.
  • Subsequent demands can be changed from GET to POST.

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

“Keep in mind: For historic factors, a user representative MAY change the request method from POST to GET for the subsequent request. If this behavior is undesired, 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.

Prior to making a change, you need to beware when utilizing a 301 redirect. The 301 redirects need to just be used when the modification to a new URL is irreversible.

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

In addition, if you change your mind later and go back to the old URL, the old URL may not rank anymore and may take some time to regain the rankings.

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

302: Found

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

The meaning of this reaction code is that the URL is temporarily at a different 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 method from POST to GET for the subsequent request. If this habits is undesired, the 307 (Short-lived Redirect) status code can be utilized instead.”

The referral to “historic factors” may refer to old or buggy user representatives that might change the request technique.

307: Temporary Redirect

A 307 redirect suggests the asked for URL is temporarily moved, and the user representative ought to utilize the original URL for future requests.

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

That means if the user agent requests the page with a GET request, then the user representative must use a GET request for the new short-term URL and can not utilize the POST request.

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

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

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

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

302 Vs. 307

You might handle a redirect by means of 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 exact same syntax for writing redirect rules. They vary just with commands used in setup files. For instance, 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 appear like this:

rewrite ^/ oldfolder// newfolder/ permanent;

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. “long-term.”
  • Action command: “RedirectMatch” vs. “reword.”

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

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

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

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

Choices +FollowSymlinks RewriteEngine on

Read the main documentation to learn more about the RewriteEngine.

To understand the examples below, you might refer to the table listed below on RegExp essentials.

* zero 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 utilized when calling $1

How To Produce Redirects

How To Create A Redirect For A Single URL

The most common and extensively utilized type of redirect is when deleting pages or altering URLs.

For example, 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 distinction between the 2 methods is that the first uses the Apache mod_rewrite module, and the second usages mod_alias. It can be done utilizing both methods.

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

We might also use (. *), i.e., ^/ old-page(. *), however the problem is, if you have another page with a comparable URL like/ old-page-other/, it will also 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 reroute any variation of the page URL to a new one. If we utilize reroute in the following form:

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 used to be shared over a social network), would wind up as 404s.

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

Redirect All Except

Let’s say 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 reroute all under/ category/ on the third line except if it is/ category/final-subcategory/ on the fourth line. We likewise have the “!-f” rule on the 2nd line, overlooking 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 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 used $1 in the target to tell the server that it need to 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 2 rules: one case with no tracking slash at the end and the other one with a trailing slash.

I could combine them into one rule utilizing (/? |. *)$ RegExp at the end, however it would cause issues and include a “//” slash to the end of the URL when the asked for URL with no routing slash has a question string (i.e., “/ old-directory? utm_source=facebook” would be redirected to “/ new-directory//? utm_source=facebook”).

Get rid of A Word From URL

Let’s state 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 guideline would be:

RewriteRule ^(. *)-chicago-(. *) http://% SERVER_NAME/$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 important part of SEO.

If missing, you may 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 exact same content.

Therefore, you must guarantee you run the site only with one variation you select.

If you want to run your site with the “www” variation, use this rule:

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 likewise part of canonicalization because URLs with a slash at the end or without are likewise dealt with differently. RewriteCond % REQUEST_FILENAME!-f RewriteRule ^(. * [^/]$/$1/ [L, R=301] This will ensure the/ example-page is rerouted to/ example-page/. You may pick to remove the slash instead of adding then you will require the other rule below: RewriteCond % REQUEST_FILENAME!-d RewriteRule ^(. *)/$/$1 [L, R=301]HTTP To HTTPS Redirect

After Google’s effort to motivate site owners to use SSL, migrating to HTTPS is among the commonly used redirects that practically every website has.

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

RewriteCond % HTTP_HOST ^ yourwebsite.com [NC, OR] RewriteCond % ^ 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 redirect into one HTTPS redirect rule.

Redirect From Old Domain To New

This is likewise among the most used redirects when you decide to rebrand and need to alter your domain. The guideline 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 utilizes two cases: one with the “www” variation of URLs and another “non-www” since any page for historic reasons might have incoming links to both versions.

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

Handling redirects using plugins might be somewhat various from what we talked about above. You might need to read their paperwork to manage RegExp properly for the specific plugin.

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

Redirect Best Practices

1. Do not 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 appropriate landing page.

According to Google, they are still all treated as 404s.

If you have a lot of pages like this, you need to think about creating gorgeous 404 pages and engaging users to browse further or find something aside from what they were searching for by displaying a search alternative.

It is highly advised by Google that redirected page material ought to be comparable to the old page. Otherwise, such a redirect might be considered a soft 404, and you will lose the rank of that page.

2. Get Mobile Page-Specific Reroutes 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 ensure to redirect users to the suitable page of the mobile variation.

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

Also, you need to guarantee that if one page is 404 on the desktop, it must also 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 Use Meta Refresh

It is possible to do a redirect utilizing a meta revitalize 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 forbid this redirect, but it doesn’t recommend using it.

According to John Mueller, online search engine may not have the ability to recognize that kind of redirect appropriately. The exact same is likewise true about JavaScript reroutes.

4. Prevent Redirect Chains

This message shows when you have an incorrect routine expression setup and ends up in a boundless loop.

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

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

redirects are and which scenario needs a particular status code is essential to

optimizing

web pages properly. It’s a core part of understanding SEO. Numerous situations require accurate understanding of redirects, such as moving a site to a new domain or developing a temporary holding page URL for a web page 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 utilize a specific

sort of redirect. More Resources: Featured Image: