URL Reroutes For SEO: A Technical Guide

Posted by

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

While most people think of redirects as a web detour sign, a lot more is happening, and it’s remarkably pleasurable to find.

Keep reading for an extensive summary of redirects and the correct application for technical SEO.

What Is A Redirect?

Website reroutes inform internet browsers and online search engine details about a URL and where to discover the web page.

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 various page to the real URL that was input or clicked.

A redirect can be set as a:

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

When To Utilize Redirects

The primary factors to use redirects are:

  • A specific page or entire domain has been moved (URL changed).
  • To enable the use 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 pointing to a page that has moved or been deleted.
  • Avoid 404 page not discovered errors (although sometimes it is better to leave a 404).

Redirects can be implemented on a group or domain-wide basis but often need to be set on a private basis to avoid issues.

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

Types Of Redirects

There are three main types of redirects:

  • Meta Refresh redirects are set at the page level but are usually not advised for SEO purposes. There are 2 kinds of meta redirect: delayed which is seen as a temporary redirect, and immediate, which is seen as a permanent redirect.
  • Javascript reroutes are likewise set on the client side’s page and can trigger SEO problems. Google has actually mentioned a choice for HTTP server-side reroutes.
  • HTTP redirects are set server-side and the best approach for SEO purposes– we covered thorough listed below.

What Is A HTTP Response Status Code?

Browsers and online search engine spiders like GoogleBot are called user agents.

When a user agent tries to access a web page, what occurs is that the user agent makes a request, and the site server problems an action.

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

In the scenario where a user representative like GoogleBot requests a URL, the server provides an action.

For instance, if the request for a URL succeeds, the server will offer a reaction code of 200, which indicates the request for a URL succeeded.

So, when you think about a GoogleBot reaching a website and attempting to crawl it, what’s taking place is a series of demands and responses.

HTTP Redirects

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

If the URL exists at a different URL (due to the fact that it was moved), the server tells the user representative that the URL request is being redirected to a various URL.

The reaction code for a changed URL is normally 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 upon by the user agent.

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

3XX Series Of Status Codes

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

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

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

  • 300 Multiple Choices.
  • 301 Moved Permanently.
  • 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 used. So, prior to using any redirect code besides 301 or 302, make certain that the designated user representative can interpret it.

Since GoogleBot uses the most recent variation of Chrome (called a headless web browser), it’s easy to check if a status code is compatible by examining if Chrome recognizes the status code with an internet browser compatibility list.

For SEO, one should stick to utilizing the 301 and 302 response codes unless there is a specific factor to use one of the other codes.

301: Moved Permanently

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

The 301 redirect shows to a user representative that the URL (often described as a target resource or simply resource) was altered to another location which it need to utilize the brand-new URL for future demands.

As mentioned previously, there is more details too.

The 301 status code likewise recommends to the user agent:

  • Future requests for the URL ought to be made with the new URL.
  • Whoever is making the request 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 concern. According to the official requirements for the 301 status code:

“Keep in mind: For historical factors, a user representative MAY alter the demand method from POST to GET for the subsequent request. If this habits is undesirable, the 308 (Long-term Redirect) status code can be used instead.”

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

Before making a modification, you need to beware when using a 301 redirect. The 301 redirects must only be utilized when the change to a brand-new URL is irreversible.

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

Additionally, if you alter your mind later on and return to the old URL, the old URL might not rank anymore and might require time to gain back the rankings.

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

302: Found

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

The significance of this reaction code is that the URL is temporarily at a various URL, and it is suggested to utilize the old URL for future demands.

The 302 redirect status code likewise comes with a technical caution related to GET and Post:

“Note: For historic reasons, a user representative MAY change the request method from POST to GET for the subsequent demand. If this habits is undesirable, the 307 (Short-term Redirect) status code can be used rather.”

The referral to “historic factors” may describe old or buggy user representatives that might change the demand approach.

307: Temporary Redirect

A 307 redirect suggests the asked for URL is temporarily moved, and the user agent ought to utilize 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 used to ask for the initial URL.

That means if the user representative requests the page with a GET request, then the user agent should use a GET ask for the brand-new short-lived URL and can not use the POST demand.

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

“The server sends this reaction to direct the customer to get the asked for resource at another URI with very same approach that was utilized in the previous request.

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

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

302 Vs. 307

You might handle 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 same syntax for writing redirect rules. They differ only with commands used 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 appear like this:

reword ^/ 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. “long-term.”
  • 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 managing redirects) are allowed on your server.

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

Make sure that the.htaccess file has these 2 lines above the redirect rules and put the rules listed below them:

Alternatives +FollowSymlinks RewriteEngine on

Read the official documents to read more about the RewriteEngine.

To comprehend the examples listed below, you may refer to the table below on RegExp essentials.

* zero or more times
+ Several times
. any single character
? Absolutely 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 Develop Redirects

How To Develop A Redirect For A Single URL

The most typical and commonly utilized type of redirect is when erasing pages or changing URLs.

For example, state 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 two approaches is that the very first uses the Apache mod_rewrite module, and the second uses mod_alias. It can be done utilizing both techniques.

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

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

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

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

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

Redirect All Except

Let’s say we have a bunch 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 except” guideline here.

RewriteCond % REQUEST_URI!/ category/final-subcategory/ RewriteCond % REQUEST_FILENAME!-f RewriteRule ^(category/)./ category/final-subcategory/ [R=301, L] Here, we wish to reroute all under/ category/ on the third line other than if it is/ category/final-subcategory/ on the 4th 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 likewise be rerouted to “/ final-subcategory/” and cause an image break.

Directory Change

You can utilize the guideline listed below if you did a category restructuring and wish to move everything 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 tell the server that it need to keep in mind everything in the URL that follows/ old-directory/ (i.e.,/ old-directory/subdirectory/) and pass it (i.e., “/ subdirectory/”) onto the destination. As an outcome, it will be rerouted to/ new-directory/subdirectory/.

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

I could integrate them into one guideline utilizing (/? |. *)$ RegExp at the end, however it would trigger problems and add a “//” slash to the end of the URL when the requested 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”).

Remove A Word From URL

Let’s state you have 100 URLs on your website with the city name “Chicago” and want 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 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 important part of SEO.

If missing, you may endanger your site with duplicate content concerns since search engines treat URLs with “www” and “non-www” variations as different pages with the exact same material.

For that reason, you must guarantee you run the website just with one version you pick.

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

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

After Google’s effort to encourage website owners to use SSL, migrating to HTTPS is among the frequently utilized redirects that practically every site has.

The reword rule listed below can be used to force HTTPS on every site.

RewriteCond % ^ 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 one of the most pre-owned redirects when you choose to rebrand and require to alter your domain. The rule listed below redirects 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 uses 2 cases: one with the “www” variation of URLs and another “non-www” since any page for historic factors might have inbound links to both variations.

Many website owners use WordPress and may not need a.htaccess declare redirects however utilize a plugin rather.

Dealing with redirects utilizing plugins may be slightly different from what we went over above. You might need to read their paperwork to deal with RegExp correctly for the particular plugin.

From the existing ones, I would advise a totally free plugin called Redirection, which has numerous criteria to control redirect rules and many useful docs.

Redirect Best Practices

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

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

If you have too many pages like this, you need to think about developing stunning 404 pages and engaging users to browse further or find something aside from what they were looking for by displaying a search option.

It is strongly advised by Google that redirected page material should be comparable 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 sites (i.e., “example.com” for desktop and “m.example.com” for mobile), you should make certain to reroute users to the proper page of the mobile version.

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

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

If you have no mobile version for a page, you can prevent rerouting 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 place this tag in/ old-page/, it will reroute the user immediately to/ new-page/.

Google does not restrict this redirect, however it does not suggest utilizing it.

According to John Mueller, search engines might not be able to acknowledge that type of redirect appropriately. The very same is also true about JavaScript redirects.

4. Prevent Redirect Chains

This message displays when you have a wrong routine expression setup and winds up in an unlimited loop.

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

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

=301, NC, L] RewriteRule ^ page2/ page1 [R=301, NC, L] This will create a boundless loop and produce the mistake revealed above. Conclusion Knowing what

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


websites properly. It’s a core part of understanding SEO. Lots of circumstances need precise knowledge of redirects, such as moving a site to a brand-new domain or creating a momentary holding page URL for a webpage that will return under its normal URL. While so much is possible with a plugin, plugins can be misused without appropriately understanding when and why to utilize a specific

type of redirect. More Resources: Included Image: