| Article Index |
|---|
| How to Redirect a Web Page | 301 redirect |
| redirect-single-page |
| All Pages |
- Users may access your page from both "www.yourdomain.com" AND "yourdomain.com" {search engines penalize your page ranking by splitting the ranks of the two}
- You have moved a page permanently. Well, users may have bookmarked a page in your site that no longer exists.
- You have links to a non-existing web page that you have posted on another site.
I'll list three of the best methods for getting a web page to redirect to another page.
Note: be sure to save a copy of your current ".htaccess" file as a backup in case you're server has issues with this tutorial.
If you have "permanently" moved a page on your site then it is best to tell the server and everyone else it has too. The best method to accomplish this known as the "301 redirect". This will tell the web browser (or more importantly the search engines) that this page has been moved to its new location. The "301" does it as soon as the page is triggered.
Redirect All Pages
When a user types in http://your-domain.com , They will automatically be redirected to  http://www.your-domain.com
mod_rewrite {my favorite method}
- Create or open a file called .htaccess in the root directory of your website.
- Open .htaccess using your favorite text editor.
- Copy and paste this code below into your file, exactly as it appears replacing your-domain.com with your domain.
**Note** if .htaccess already exists, you can usually append this to it.
Code:# mod_rewrite in use
RewriteEngine On
######## BEGIN www Search Engine Redirect
# Rewrites url http://your-domain.com
# as http://www.your-domain.com
# this prevents search engines from splitting your ranks
# on the two
rewritecond %{http_host} ^your-domain.com
rewriteRule ^(.*) http://www.your-domain.com/$1 [R=301,L]
####### END Search Engine Redirect - Save .htaccess to the root directory of your website {usually where your main homepage is located}




