Gadgets Magazine

How to Use 301 Redirect and 302 Redirect

Posted on the 19 October 2012 by Yogeshvashist98 @YogeshVashist98

In the life of an SEO, it necessarily becomes a point to have to get by with pages missing or URLs you would like to make it more readable, both for engines or users. We must fight more or less with the htaccess file located in the root of the site or within a folder.

Today we will therefore look at the file a bit barbaric but so useful.

The .htaccess file, what is it?

This is a file that gives instructions to the server, it shows commands to follow. In practice, it is thanks to him that we can protect page password or you can manage the different error pages (404, 401, 403, etc.). It also allows redirection pages and URL rewriting. Today I will tell you about the redirection, whether permanent or temporary.

For information, This file is called htaccess , nothing to the point, for we can not open the htaccess any site from their browser (this info was unnecessary to do well in lunches worldly). If you want to edit, open it directly from your FTP software or download it by renaming it and put whatever you want in front of the point. Do not forget to delete what you have put before this point once you return the file to the server.

301 redirection

The 301 redirect

The so-called permanent redirection is used mostly in a site redesign when some pages are moved or deleted. It can not end up with a 404 error (page not found) and retain the benefit of links made to this page.

The 301 redirect can be done in two ways: with plain text or regular expressions (sequences of characters a bit strange). We will see here the first method, do not forget that Noviseo is aimed at beginners. Redirection regular expression will certainly be a separate article to detail everything.

Method with text is the easiest to achieve. Clearly, we told the waiter what we do (a permanent redirect), it gives the redirect page and tells him where she is going. In practice it looks like this:

RedirectPermanent / ancien-dossier/ancienne-page.html http://www.domaine.com/nouveau-dossier/nouvelle-page.html

RedirectPermanent / old-folder http://www.domaine.com/nouveau-dossier

RedirectPermanent / http://www.domaine.com/

Specifically, that what these examples:

  • The first line allows you to redirect a single page
  • The second line redirects a complete (with its subfolders and pages)
  • The third line allows you to redirect a domain to a new domain (aves records and pages)

I used RedirectPermanent the previous code, but you should know that Permanent Redirect and Redirect 301 also function.

The 302 redirect

The temporary redirect is rarely used. It can be when you edit a page directly online and you do not want the user sees the work or when you for example a marketing on your site. Google understands that the redirection is not definitive, it does not give the weight of the links to the new page.

Like a 301, a temporary redirect can be done with text or regular expressions. Again you will see only the version with text only. And the method is the same as before, we’ll just change what they say to the server (a temporary redirect and not a permanent redirect).

Redirect / ancien-dossier/ancienne-page.html http://www.domaine.com/nouveau-dossier/nouvelle-page.html

Redirect / old-folder http://www.domaine.com/nouveau-dossier

Redirect / http://www.domaine.com/


Back to Featured Articles on Logo Paperblog

Magazines