URL Redirects For SEO: A Technical Guide via @sejournal, @vahandev

Redirects for SEO should be used correctly because they impact how websites are crawled and indexed by Google.

While most people think of redirects as an internet detour sign, much more is happening, and it’s surprisingly enjoyable to discover.

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

What Is A Redirect?

Website redirects tell browsers and search engines information about a URL and where to find the webpage.

A URL redirect involves code implemented to a specific URL, or a group of URLs so that the user (or 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.
Permanent redirect: 301.

When To Use Redirects

The main reasons to use redirects are:

An individual page or entire domain has been moved (URL changed).
To allow the use of URL shorteners or ‘pretty URLs.’
Site migration (e.g., HTTP to HTTPS).

For SEO purposes, URL redirects are important because they:

Forward authority of any links pointing to a page that has moved or been deleted.
Avoid 404 page not found 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 an individual basis to avoid issues.

When using RegEX for group redirects, it can have unexpected results 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 generally not recommended for SEO purposes. There are two types of meta redirect: delayed which is seen as a temporary redirect, and instant, which is seen as a permanent redirect.
Javascript redirects are also set on the client side’s page and can cause SEO issues. Google has stated a preference for HTTP server-side redirects.
HTTP redirects are set server-side and the best approach for SEO purposes – we covered in-depth below.

What Is A HTTP Response Status Code?

Browsers and search engine crawlers like GoogleBot are called user agents.

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

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

In the situation where a user agent like GoogleBot requests a URL, the server gives a response.

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

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

HTTP Redirects

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

If the URL exists at a different URL (because it was moved), the server tells the user agent that the URL request is being redirected to a different URL.

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

The entire 3xx series of response codes communicate much information that can optionally be acted upon by the user agent.

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 requested, it will ask for the new URL instead.

So, a 301 and a 302 redirect is more than an internet road 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 a total of seven official 3xx response status codes.

These are the different kinds of redirects available for use:

300 Multiple Choices.
301 Moved Permanently.
302 Found.
303 See Other.
304 Not Modified.
305 Use Proxy.
306 (Unused).
307 Temporary Redirect.
308 Permanent Redirect.

Some of the above status codes have not been around as long and might not be used. So, before using any redirect code other than 301 or 302, be sure that the intended user agent can interpret it.

Because GoogleBot uses the latest version of Chrome (called a headless browser), it’s easy to check if a status code is compatible by checking if Chrome recognizes the status code with a browser compatibility list.

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

301: Moved Permanently

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

The 301 redirect indicates to a user agent that the URL (sometimes referred to as a target resource or simply resource) was changed to another location and that it should use the new URL for future requests.

As mentioned earlier, there is more information as well.

The 301 status code also suggests to the user agent:

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

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

“Note: For historical reasons, a user agent 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 search engines see a 301 redirect, they pass the old page’s ranking to the new one.

Before making a change, you must be careful when using a 301 redirect. The 301 redirects must only be used when the change to a new URL is permanent.

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

Additionally, if you change your mind later and return to the old URL, the old URL may not rank anymore and may take time to regain the rankings.

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

302: Found

The main thing to understand about the 302 status code is that it’s useful for situations where a URL is temporarily changed.

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

“Note: For historical reasons, a user agent MAY change the request method from POST to GET for the subsequent request. If this behavior is undesired, the 307 (Temporary Redirect) status code can be used instead.”

The reference to “historical reasons” may refer to old or buggy user agents that may change the request method.

307: Temporary Redirect

A 307 redirect means the requested URL is temporarily moved, and the user agent should use the original URL for future requests.

The only difference between a 302 and a 307 status code is that a user agent must request the new URL with the same HTTP request used to request the original URL.

That means if the user agent requests the page with a GET request, then the user agent must use a GET request for the new temporary URL and cannot use the POST request.

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

“The server sends this response to direct the client to get the requested resource at another URI with same method that was used in the prior request.

This has the same semantics as the 302 Found HTTP response code, with the exception that the user agent must not change the HTTP method used: if a POST was used in the first request, a POST must be used in the second request.”

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

302 Vs. 307

You may handle a redirect via 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 same syntax for writing redirect rules. They differ only with commands used in configuration files. For example, a redirect on Apache will look like this:

Options +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 used to tell 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.”

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

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

Since the most widely 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 rules and put the rules below them:

Options +FollowSymlinks
RewriteEngine on

Read the official documentation to learn more about the RewriteEngine.

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

zero or more times
One or more times
any single character
Zero or one time
Start of the string
End of the string
a” a or b
remembers the match to be used when calling $1

How To Create Redirects

Single URL Redirect
Redirect All Except
Directory Change
Remove A Word From URL
Set A Canonical URL
HTTP To HTTPS Redirect
Redirect From Old Domain To New

How To Create A Redirect For A Single URL

The most common and widely used type of redirect is when deleting pages or changing URLs.

For instance, say you changed the URL from /old-page/ to /new-page/. The redirect rule would be:

RewriteRule ^old-page(/?

Leave a Reply

Your email address will not be published. Required fields are marked *