How to create a 301 redirect with an Apache server?

The best way to set up a 301 redirect on a website is always to define it directly into your server configuration. This way, you can be certain all your redirect instructions are centralized in a single position and you'll not need multiple editing the day you want to modify them.



Requested configuration.
Setting up 301 redirects on an Apache server only requests the presence of the Mod_Alias module on this server. Coming with most server configurations and Apache versions, this module allows to dynamically set up aliases between different URL and to define permanent of temporary redirections.

Once this module activated on your Apache server, the definition of 301 redirects is only a matter of some command line defined in a .htaccess file on the root of your website. On an Apache server configuration, this .htaccess file contains all the commands and controls your server must execute before accessing a file located within the same directory. By placing your redirection process into the .htaccess file located at the root of your site, you're certain it will be checked before any access to a file of your site.



Setting up the redirection.
In its basical configuration, 301 redirect on Apache server just stands in one line:

Redirect permanent /index.html http://www.newlocation.com

This line is simply defining that any access to index.html, located on the same level as the .htaccess file containing this command, must be redirected permanently to the new address http://www.newlocation.com.



Creative Commons License
This site is available uder Creative Commons licence.