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).
One thought on “Howto redirect or forward a link / url via .htaccess”
Howdy I am so thrilled I found your blog page, I really found
you by error, while I was browsing on Aol for something else, Nonetheless
I am here now and would just like to say cheers for a fantastic post
and a all round interesting blog (I also love the theme/design), I don’t have time to browse it all at the moment but I have book-marked it and
also included your RSS feeds, so when I have time I will
be back to read a lot more, Please do keep up the excellent work.