URL Reroutes For SEO: A Technical Guide

Posted by

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

While the majority of people consider redirects as an internet detour indication, far more is happening, and it’s surprisingly pleasurable to discover.

Keep reading for a comprehensive summary of redirects and the proper application for technical SEO.

What Is A Redirect?

Site reroutes tell web browsers and search engines info about a URL and where to find the website.

A URL redirect involves code implemented 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 actual URL that was input or clicked.

A redirect can be set as a:

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

When To Use Redirects

The main factors to use redirects are:

  • An individual page or entire domain has actually 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 essential because they:

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

Redirects can be implemented on a group or domain-wide basis but typically require to be set on a specific basis to avoid issues.

When using RegEX for group reroutes, it can have unexpected outcomes if your reasoning isn’t flawless!

Types Of Redirects

There are three main kinds of redirects:

  • Meta Refresh redirects are set at the page level however are typically not recommended for SEO functions. There are two kinds of meta redirect: delayed which is viewed as a momentary redirect, and instant, which is viewed as a long-term redirect.
  • Javascript redirects are likewise set on the customer side’s page and can trigger SEO problems. Google has actually stated a preference for HTTP server-side redirects.
  • HTTP redirects are set server-side and the best approach for SEO functions– we covered thorough listed below.

What Is A HTTP Response Status Code?

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

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

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

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

For example, if the ask for a URL achieves success, the server will supply an action code of 200, which suggests the ask for a URL was successful.

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

HTTP Reroutes

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 request is being rerouted to a different URL.

The reaction 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 communicate much info that can optionally be acted upon 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 request for the new URL rather.

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

3XX Series Of Status Codes

Redirects are more than just the two status codes everybody recognizes with, the 301 and 302 response codes.

There are an overall of seven main 3xx action 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 Usage 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, be sure that the designated user agent can translate it.

Due to the fact that GoogleBot uses the most recent version of Chrome (called a headless internet browser), it’s simple to examine if a status code is compatible by inspecting if Chrome recognizes the status code with a browser compatibility list.

For SEO, one ought 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 regularly referenced as the 301 redirects. However the main name is 301 Moved Permanently.

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

As pointed out previously, there is more info too.

The 301 status code also suggests to the user agent:

  • Future requests for the URL must be made with the new URL.
  • Whoever is making the request should update their links to the new URL.
  • Subsequent demands can be altered from GET to POST.

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

“Note: For historical reasons, a user representative MAY alter the request technique from POST to GET for the subsequent request. If this habits is unwanted, the 308 (Permanent Redirect) status code can be utilized rather.”

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

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

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

Additionally, if you change your mind later on and go back to the old URL, the old URL might not rank any longer and might require time to restore the rankings.

So, the main thing to remember is that a 301 status code will be used when the modification is long-term.

302: Found

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

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

The 302 redirect status code also includes a technical caveat associated to GET and Post:

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

The reference to “historic factors” might refer to old or buggy user agents that may alter the request approach.

307: Temporary Redirect

A 307 redirect indicates the requested URL is temporarily moved, and the user representative must utilize the initial URL for future requests.

The only distinction in between a 302 and a 307 status code is that a user representative must request the brand-new URL with the very same HTTP request utilized to request the original URL.

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

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

“The server sends this reaction to direct the client to get the requested resource at another URI with same method that was utilized in the prior demand.

This has the same semantics as the 302 Found HTTP action code, with the exception that the user agent must not alter the HTTP technique utilized: if a POST was utilized in the very first demand, a POST should be utilized in the second demand.”

Besides the 307 status code requiring subsequent requests to be of the exact same kind (POST or GET) and that the 302 can go in either case, whatever else is the exact same in between the 302 and the 307 status codes.

302 Vs. 307

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

In all circumstances, they have the exact same syntax for composing redirect guidelines. They vary just with commands utilized in setup files. For example, a redirect on Apache will look like this:

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

(You can read about symlinks here.)

On Nginx servers, it will look like this:

rewrite ^/ oldfolder// newfolder/ permanent;

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

For example:

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

However 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 enabled on your server.

Since the most extensively spread 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 guidelines listed below them:

Options +FollowSymlinks RewriteEngine on

Read the official documents for more information about the RewriteEngine.

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

* 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 Develop Redirects

How To Develop A Redirect For A Single URL

The most common and extensively used kind of redirect is when deleting pages or changing URLs.

For instance, 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 difference between the two techniques is that the very first utilizes the Apache mod_rewrite module, and the 2nd uses mod_alias. It can be done using 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 redirected to/ new-page/.

We could also utilize (. *), 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 rerouted 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 redirect any variation of the page URL to a brand-new one. If we utilize redirect in the list below form:

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

Without routine expressions, all URLs with UTM query string, e.g.,/ old-page? utm_source=facebook.com (which is common since URLs are utilized to be shared over a social media), would end up as 404s.

Even/ old-page without a trailing 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 combine all subcategories into/ category/final-subcategory/. We need the “all other than” rule here.

RewriteCond % REQUEST_URI!/ category/final-subcategory/ RewriteCond % REQUEST_FILENAME!-f RewriteRule ^(classification/)./ category/final-subcategory/ [R=301, L] Here, we want to redirect all under/ classification/ on the third line other than if it is/ category/final-subcategory/ on the fourth line. We also have the “!-f” guideline on the second line, neglecting any file like images, CSS, or JavaScript files.

Otherwise, if we have some properties 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 listed below if you did a category restructuring and wish to move whatever 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 need to remember everything 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 rerouted to/ new-directory/subdirectory/.

I utilized 2 rules: one case with no routing slash at the end and the other one with a routing slash.

I could combine them into one guideline using (/? |. *)$ RegExp at the end, however it would trigger issues and add a “//” slash to the end of the URL when the requested URL without any trailing slash has a query string (i.e., “/ old-directory? utm_source=facebook” would be redirected to “/ new-directory//? utm_source=facebook”).

Eliminate A Word From URL

Let’s state 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 guideline 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 issues since online search engine treat URLs with “www” and “non-www” versions as various pages with the same content.

For that reason, you need to ensure you run the site only with one version you select.

If you want 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” variation: RewriteCond % HTTP_HOST ^ www.yourwebsite.com [NC] RewriteRule ^(. *)$ http://yourwebsite.com/$1 [L, R=301] Routing slash is also part of canonicalization considering that URLs with a slash at the end or without are likewise dealt with in a different way. RewriteCond % REQUEST_FILENAME!-f RewriteRule ^(. * [^/]$/$1/ [L, R=301] This will make sure the/ example-page is redirected to/ example-page/. You may select to eliminate the slash rather 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 effort to encourage site owners to use SSL, moving to HTTPS is one of the frequently utilized redirects that nearly every website has.

The reword guideline below can be used to force 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 integrate a www or non-www version reroute into one HTTPS redirect rule.

Redirect From Old Domain To New

This is likewise 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 % HTTP_HOST ^ 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” because any page for historic reasons may have inbound links to both versions.

The majority of website owners use WordPress and may not require a.htaccess declare redirects however use a plugin rather.

Managing redirects using plugins might be a little various from what we went over above. You might require to read their paperwork to manage RegExp properly for the specific plugin.

From the existing ones, I would recommend a free plugin called Redirection, which has many specifications to manage redirect rules and many helpful docs.

Reroute Finest Practices

1. Do not Reroute 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 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 developing gorgeous 404 pages and engaging users to search additional or discover something besides what they were trying to find by displaying a search alternative.

It is strongly suggested by Google that rerouted page material should be equivalent to the old page. Otherwise, such a redirect may be considered 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 websites (i.e., “example.com” for desktop and “m.example.com” for mobile), you need to ensure to reroute 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”

Likewise, you need to make sure that if one page is 404 on the desktop, it ought to likewise be 404 on mobile.

If you have no mobile variation for a page, you can prevent rerouting to the mobile version 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 redirect the user immediately to/ new-page/.

Google does not prohibit this redirect, but it does not recommend using it.

According to John Mueller, search engines might not be able to recognize that type of redirect appropriately. The same is likewise true about JavaScript reroutes.

4. Prevent Redirect Chains

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

Screenshot by author, December 2022 Generally, 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 once 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 a boundless loop and produce the error shown above. Conclusion Understanding what

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

optimizing

websites effectively. It’s a core part of comprehending SEO. Lots of circumstances need precise understanding of redirects, such as migrating a site to a new domain or creating a temporary holding page URL for a web page that will return under its regular URL. While so much is possible with a plugin, plugins can be misused without appropriately comprehending when and why to utilize a specific

sort of redirect. More Resources: Featured Image: