Apache 301 RedirectPermanent

Sometime, one needs to redirect part of a web site or the whole web site permanently to another location.

The full documentation is available at Apache.org

Here is how to do it on our Servers, using Apache .htaccess and 301 (RedirectPermanent)

1- Create a file named .htaccess (htaccess) using a text editor like Notepad or Textedit.
Do not use Word or other editors as they insert extra characters in the file, and this will cause errors.

2- Set up the redirect directives.

To redirect a single page:

Redirect 301 /myoldpage.html http://mynewpage.html


RedirectPermanent /myoldpage.html http://mynewpage.html

To redirect all pages in a sub-directory:

Redirect 301 /olddir http://foobar.com/newdir


RedirectPermanent /olddir http://foobar.com/newdir

To redirect the whole site:

Redirect 301 / http://mynewsite.com


RedirectPermanent / http://mynewsite.com

Note that the file will be read from top to bottom,
so if you need to set up multiple redirections, always start with the single pages redirects, then setup the redirections for sub-folders, folders and end with the whole web site redirection.

3- Upload the .htaccess file at the document root of your web site.
They will be active immediately.

Properties ID: 000205   Views: 5732   Updated: 13 years ago
Filed under: