This article explains how to use the mod_rewrite function to redirect a URL on your web site to a new location.
This article applies to Linux Dedicated Servers.
mod_rewrite can be used for a number of purposes, from preventing hot-linking of your web site images, to redirecting users from dead links on your site to a new page which would avoid the user receiving a 404 page not found error.
1
Open your preferred text editor and enter your required mod_rewrite code. The example below shows how to redirect www.yourdomain.com/index.html to www.yourdomain.com/newindex.html
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteRule ^index\.html$ newindex.html
2
Save the file with the name .htaccess.
3
Upload the file via FTP to the same folder as the files you wish to perform the URL rewrite on.
Tip: For more detailed information on the syntax to use for mod_rewrite, please refer to the Apache HTTP Server URL Rewriting Guide.