URL Redirects For SEO: A Technical Guide

Posted by

Redirects for SEO ought to be utilized correctly because they affect how websites are crawled and indexed by Google.

While most people consider redirects as an internet detour indication, a lot more is happening, and it’s surprisingly satisfying to discover.

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

What Is A Redirect?

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

A URL redirect includes code carried out to a particular URL, or a group of URLs so that the user (or search engine) is sent 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.
  • Long-term redirect: 301.

When To Utilize Redirects

The primary reasons to use redirects are:

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

For SEO purposes, URL redirects are very important since they:

  • Forward authority of any links pointing to a page that has actually moved or been deleted.
  • Prevent 404 page not found mistakes (although sometimes it is much 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 prevent concerns.

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

Kinds of Redirects

There are 3 main kinds of redirects:

  • Meta Refresh redirects are set at the page level however are usually not advised for SEO purposes. There are two kinds of meta redirect: delayed which is seen as a short-term redirect, and immediate, which is viewed as a permanent redirect.
  • Javascript redirects are also set on the client side’s page and can trigger SEO issues. Google has actually stated a choice for HTTP server-side reroutes.
  • HTTP redirects are set server-side and the very best technique for SEO functions– we covered thorough below.

What Is A HTTP Action Status Code?

Web browsers and search engine crawlers like GoogleBot are called user agents.

When a user representative tries to access a website, what happens is that the user agent makes a request, and the website server issues an action.

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

In the circumstance where a user agent like GoogleBot demands a URL, the server provides an action.

For instance, if the ask for a URL achieves success, the server will supply an action code of 200, which implies the ask for a URL succeeded.

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

HTTP Reroutes

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

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

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

The whole 3xx series of action codes communicate much information that can optionally be acted on 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 request the new URL instead.

So, a 301 and a 302 redirect is more than a web roadway indication that says, “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 response codes.

There are an overall of seven main 3xx action status codes.

These are the various sort of redirects offered for usage:

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

Some of the above status codes have not been around as long and may not be utilized. So, before using any redirect code other than 301 or 302, make certain that the designated user representative can translate it.

Since GoogleBot uses the most recent variation of Chrome (called a headless web browser), it’s simple to inspect if a status code works by checking if Chrome recognizes the status code with an internet browser compatibility list.

For SEO, one must stay with using the 301 and 302 action codes unless there is a specific reason to use among the other codes.

301: Moved Completely

The 301 status code is routinely referenced as the 301 redirects. But the official name is 301 Moved Completely.

The 301 redirect indicates to a user representative that the URL (often described as a target resource or just resource) was changed to another place and that it must utilize the new URL for future demands.

As pointed out previously, there is more info also.

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 demand ought to upgrade 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 standards for the 301 status code:

“Note: For historic factors, a user agent MAY alter the request approach from POST to GET for the subsequent demand. If this habits is unwanted, the 308 (Irreversible Redirect) status code can be used rather.”

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 modification, you need to be careful when utilizing a 301 redirect. The 301 redirects need to just be used when the modification to a brand-new URL is irreversible.

The 301 status code must not be used when the modification is short-term.

In addition, if you alter your mind later on and return to the old URL, the old URL might not rank any longer and may take time to restore 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 point to comprehend about the 302 status code is that it’s useful for situations where a URL is briefly altered.

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

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

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

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

307: Temporary Redirect

A 307 redirect suggests the asked for URL is briefly moved, and the user representative should utilize the original URL for future requests.

The only distinction in between a 302 and a 307 status code is that a user agent need to request the new URL with the very same HTTP request utilized to ask for the original URL.

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

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

“The server sends this response to direct the customer to get the requested resource at another URI with same approach that was utilized in the prior request.

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

Aside from the 307 status code needing subsequent requests to be of the very same kind (POST or GET) and that the 302 can go in any case, whatever else is the same between the 302 and the 307 status codes.

302 Vs. 307

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

In all circumstances, they have the same syntax for composing redirect rules. They differ just with commands used in setup files. For example, a redirect on Apache will appear like this:

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

(You can read about symlinks here.)

On Nginx servers, it will look like this:

rewrite ^/ oldfolder// newfolder/ irreversible;

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 very same for both.

On Apache, ensure that mod_rewrite and mod_alias modules (accountable for managing redirects) are allowed on your server.

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

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

Alternatives +FollowSymlinks RewriteEngine on

Read the main documentation to read more about the RewriteEngine.

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

* absolutely no or more times
+ One or more 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 used when calling $1

How To Create Redirects

How To Create A Redirect For A Single URL

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

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

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

We could also utilize (. *), i.e., ^/ old-page(. *), however the issue is, if you have another page with a similar URL like/ old-page-other/, it will likewise be rerouted when we just wish to redirect/ 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 new one. If we use redirect in the following form:

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

Without regular 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 media network), would wind up as 404s.

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

RewriteCond % !/ category/final-subcategory/ RewriteCond % !-f RewriteRule ^(classification/)./ category/final-subcategory/ [R=301, L] Here, we wish to redirect all under/ classification/ on the third line except if it is/ category/final-subcategory/ on the 4th line. We likewise have the “!-f” guideline on the 2nd line, ignoring any file like images, CSS, or JavaScript files.

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

Directory site Modification

You can utilize the rule listed below if you did a category restructuring and want to move whatever from the old directory 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 used $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 location. As a result, it will be redirected to/ new-directory/subdirectory/.

I used 2 guidelines: one case with no trailing slash at the end and the other one with a trailing slash.

I could integrate them into one rule using (/? |. *)$ RegExp at the end, however it would cause problems and include a “//” slash to the end of the URL when the asked for URL without any trailing 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 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://% 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://% /$1/$2 [NC, R=301, L] Set A Canonical URL

Having canonical URLs is the most fundamental part of SEO.

If missing, you might endanger your site with replicate content issues because online search engine deal with URLs with “www” and “non-www” variations as various pages with the very same material.

Therefore, you need to guarantee you run the website just with one variation you choose.

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

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 likewise dealt with differently. RewriteCond % !-f RewriteRule ^(. * [^/]$/$1/ [L, R=301] This will ensure the/ example-page is redirected to/ example-page/. You may select to get rid of the slash rather of including then you will need the other guideline below: RewriteCond % !-d RewriteRule ^(. *)/$/$1 [L, R=301]HTTP To HTTPS Redirect

After Google’s effort to motivate website owners to use SSL, moving to HTTPS is one of the typically used redirects that almost every website has.

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

RewriteCond % HTTP_HOST ^ 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 combine 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 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 uses 2 cases: one with the “www” variation of URLs and another “non-www” because any page for historical reasons might have incoming links to both versions.

A lot of site owners use WordPress and might not require a.htaccess file for redirects however use a plugin instead.

Managing redirects using plugins might be a little different from what we discussed above. You may require to read their documents to manage RegExp correctly for the specific plugin.

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

Reroute Best Practices

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

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

If you have too many pages like this, you ought to think about developing lovely 404 pages and engaging users to search further or discover something other than what they were looking for by showing a search option.

It is highly suggested by Google that redirected page content need 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 different URLs for desktop and mobile sites (i.e., “example.com” for desktop and “m.example.com” for mobile), you should make sure to redirect 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”

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

If you have no mobile variation for a page, you can prevent 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 using 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 restrict this redirect, however it doesn’t advise using it.

According to John Mueller, search engines may not have the ability to recognize that type of redirect properly. The exact same is likewise real about JavaScript reroutes.

4. Avoid Redirect Chains

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

Screenshot by author, December 2022 Normally, this occurs when you have a redirect chain. Let’s state you rerouted 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 once again. As an outcome, 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 produce a limitless loop and produce the mistake revealed above. Conclusion Understanding what

redirects are and which situation needs a specific status code is basic to


webpages properly. It’s a core part of comprehending SEO. Numerous scenarios need exact understanding of redirects, such as moving a site to a brand-new domain or creating a short-term 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 appropriately comprehending when and why to use a particular

type of redirect. More Resources: Featured Image: