Redirect old webpages or domain names to a new destination using 301 redirect rules with .htaccess
June 15th, 2007
Have you ever needed to change a page name on your website or even thought of revamping or redesigning your entire website! or your company or client suddenly decided to move a site to a new domain name! Changing a domain name or even a page name after building a good reputation with search engines and gaining a good pagerank on Google could be a disaster no matter what the reason was. Well all of the above will fine when using 301 redirects or SEF redirects “Search Engine Friendly Redirects”
a 301 redirect is the best method to preserve your current search engine rankings when redirecting web pages or a web
site. The code “301″ is interpreted as “moved permanently” and can be implemented by creating a .htaccess file.
The .htaccess file contains specific instructions for certain requests, including security, redirection issues and how to handle certain errors. When a visitor or spider requests a web page, your web server checks for a .htaccess file and follows the rules noted in that file. This files usually resides on the root of your web host directory.
When search engines spiders your site again they will follow the rule you have created in your .htaccess file. The search engine spider doesn’t actually read the .htaccess file content, but it recognizes the response from the server as valid.
During the next update, the old file name and path will be dropped and replaced with the new one. Sometimes you may see alternating old/new file names during the transition period, plus some fluctuations in rankings. According to Google it will take 6-8 weeks to see the changes reflected on your pages.
There are several way to implement a 301 redirect rule, it can be a single page redirection or a general redirection using regular expressions, below are some ways that i use and recommend of using:
-
Redirect a single webpage to a new destination
-
To redirect ALL files on your current domain
-
If you need to redirect current-domain.com to www.current-domain.com
-
redirect .php pages to .html or can be any other extension
redirect 301 /old-directory/old-page.html http://www.samedomain.com/new-page.htm
The above means a request to permanently redirect the old page in the old directory to the new page name on the same domain, it can be used in many variations all derived from the above example. Below are some other methods that can be used.
redirect 301 /index.html http://www.current-domain.com/index.html
redirect permanent /index.html http://www.current-domain.com/index.html
redirectpermanent /index.html http://www.current-domain.com/index.html
This will redirect “index.html” to another domain using a 301-Moved permanently redirect.
redirectMatch 301 ^(.*)$ http://www.current-domain.com
redirectMatch permanent ^(.*)$ http://www.current-domain.com
*Remember: For this you need mod_rewrite enabled on you web server.
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^current-domain\.com
RewriteRule ^(.*)$ http://www.current-domain.com/$1 [R=permanent,L]
or this can be used instead:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
Note: As a best practice, Always try to use your full URL (i.e. http://www.domain.com) when obtaining incoming links to your site. Also use your full URL for the internal linking of your site.
*Remember: For this you need mod_rewrite enabled on you web server.
RewriteEngine on
RewriteBase /
RewriteRule (.*).php$ /$1.html
The Butter!: The best and safest way to redirect old web pages to new pages or old domain to the new domain and keep the same search engine rankings is to use the 301 redirect rules. It will also pass on the page rank from your old site to your new site easily after sometime.












July 9th, 2007 at 10:46 am
Thanks for valuable details, I used it on my website.
July 19th, 2007 at 12:43 am
Thank you for the cool site