Howto redirect or forward a link / url via .htaccess

If you want to redirect / forward a link / url the easiest solution is to use a .htaccess file. You need to place it in the directory where the user would normally land with the original link.

The general structure is simple. You´ll only need to enter one single line in the .htaccess file:

Redirect permanent old location new location

  • old location must be a relative link to root of your server structure, e.g. /wwwroot/index.html
  • new location must be a full link, e.g.  http://www.yoursite.de/index.html

So in case you want to redirect http://www.mysite.com/index.html to http://www.my-new-site.com/index.html your .htaccess file needs to be placed in the same directory where the index.html is and should look like this:

Redirect permanent /wwwroot/index.html http://www.my-new-site.com/index.html

If you want to redirect something like this http://www.mysite.com/uploads/12/myuploadedfile.rar to this new location http://www.my-new-site.com/download/myuploadedfile.rar then your .htaccess file needs to be placed in the “12” directory and should look like this:

Redirect permanent /wwwroot/uploads/12/myuploadedfile.rar http://www.my-new-site.com/download/myuploadedfile.rar

Remember: The /wwwroot/ can be different on your site / server. You need to find out the webservers document root. A common directory is also /public_html/.

Thx to the RBI @ Uni Frankfurt – see their site for more information about url redirecting (only in german).