The easiest way to redirect your visitors from one site to another or one page to another is to use an .htaccess redirect. This has no delay since before a page is loaded in the browser the server first checks for an .htaccess file. If an htaccess then is detected the old page/site never loads, instead visitors are sent directly to the new page/site.
Here are a few well documented methods to redirect:
Important notes about htaccess redirection
- Always be sure to upload .htaccess files in ascii mode, loading it in binary will cause it to not function.
- .htaccess only works on a Linux server.
- Make sure you triple check your changes. Clear your cache and look, test the server headers to make sure you see a 301 (that means its permanent) not a 302 (temporary) unless you are absolutely sure you really mean temporary.
- Since some operating systems don’t allow you to make a file without something before the “.” you may need to save it as something.htaccess, some may even have to save it as htaccess.txt and change it once you’ve uploaded it.
- Make sure your ftp program will show .htaccess files (FileZilla does and is free).
- Double check that you’re not overwriting an old htaccess (some servers already place one there for your custom 404 pages etc.)
- Make sure you replace sample.com with your own sites URL
301 Redirect Examples
To Move a single page
To Move an entire site
Changed file extension?
This example is perfect if you’ve decided to switch to .php from .html pages. It will look for any .html page and redirect it to .php (ie http://www.example.com/yourpage.html and redirect it to http://www.example.com/yourpage.php). Be careful with this, it does mean any html page.
Redirect www to non www version of site
It’s best to stick with either always using www.example.com or just example.com. Allowing both can confuse the search engines. So here’s how to force your site to always show the non-www version. (Search for “canonical url errors” in your favorite search engine for more info.)
Note: If you do use either of the next 2 codes below, and use a secure server (ie. https:) be sure to check that it doesn’t redirect the secure to the insecure version.
Redirect non-www to www
Same as above except in the reverse, this one forces the www. into your url.
Redirect example.com/index.php to example.com/
Another snippet that is a good idea to make sure search engines don’t give you a duplicate content penalty, this will also redirect example.com/folder/index.php to example.com/folder/.
Popularity: 54% [?]








