URL redirects (HTTP 301, 302)

What is a redirect?

Resources available on the Internet are accessible via URLs (see the article on URLs). Sometimes the person who manages a website may want to change the location of a resource (because they want to change the structure of the site, for example). However, if some users were accustomed to the old location (e.g. they were using a bookmark in their browser) and they try to access it, they will encounter an error. Fortunately, there is a simple solution: the webmaster can set up a redirection of the old URL to the new one. The browser will magically follow the new path, the client will access the requested resource and the new URL will be displayed in the browser.

Redirection 301

There may be other possible scenarios, but the main principle stays the same.

Technically, a redirection is done at a HTTP protocol level. When the browser contacts the Web server on an "old" URL, the latter responds with a specific HTTP code (301 or 302) and also indicates the "new" URL (via HTTP fields Location).

What type of redirects should you choose for your website?

Depending on the HTTP response code, there are 2 types of redirects:

  • 301 "Moved permanently": is a permanent redirect to an URL mentioned in the response ('Location' field). This is a Google friendly redirect and does not impact your SEO and your rankings)
  • 302 "Moved temporarily": this is a temporary redirect to a specific URL. It's less appreciated by Google

How to implement a redirect

Technically there are several ways to set up a redirect. It all depends on your needs, your technical resources and the modularity offered by your web platform. So, redirects can be made on four different levels:

  • on a registrar level (this is the company that manages your domain name, for example Gandi). Most registrars allow you to implement redirects through their management interface. This is especially useful for globally redirecting an entire domain to another domain (e.g. redirecting www.test.com to beta.test.com). You do not need coding knowledge to implement this type of redirection.
  • at a Web server level(for example Apache or IIS): it is possible to configure redirects by changing the configuration files of the Web server (.htaccess, or httpd.conf on Apache). In order to use this redirection method, you need to be familiar with server administration. Thanks to the use of regular expressions, this is a very flexible and powerful method.
  • through server side scripting (in PHP, ASP language...). In this case, you need basic web development knowledge to implement the redirects. This method is powerful but sometimes less flexible than the previous one (especially because a developer must be involved every time in the process).
  • through client side coding (using Javascript). This method is useful when a user action should lead to a new page. However, it is not recommended for constant redirections, because it does not use the standard redirection mechanism at a HTTP level (301, 302). Moreover, a search engine spider will not necessarily know how to interpret it correctly.

URL's redirection and URL Rewriting are not the same thing

A redirection is visible to the user because the URL changes in the browser bar. Instead, a URL Rewriting is invisible to the end user, because the rewrite is done internally, on the server (see the article on URLs for a more detailed description.)

Yakaferci, the free tool that analyzes your redirections

Yakaferci provides you with a great tool for validating redirections.

"Analyze your 301 and 302 redirects with our free SEO Page Analyzer

To start the Yakaferci analysis, simply enter the URL of the page in the area above and click the Analyze button. You will then have access to different sections of the report, especially those on redirection.