Website Helpers.comArticles, tips, and resources for webmasters |
a project by Michael Bluejay | email |
|
Moving a site to another domain, or even renaming a page, always carries the risk of losing rankings, usually temporarily, but possibly long-term. Using Apache 301 Redirects as discussed below is supposed to preserve your rankings, but my experience is that that doesn't work in every case. The best strategy is the old saying: An ounce of prevention is worth a pound of cure. Spend some time choosing a good domain name and planning your directory structure and filename conventions so you don't find yourself wanting to change filenames or directory names once the site is already set up and you're already ranking well. That advice is all well and good, but you'll still find yourself in a position someday where you want or need to move or rename files, or even change domain names. The best way to do this is with the Redirect command in the Apache server software. If you're using some other kind of server software (e.g., Microsoft) then I don't know how redirecting is done and I can't help you. Redirect commands are placed in the < .htaccess> file at the top level of the server (the same level where your <index.html> file is). If you already have such a file there you can edit it. If there's no .htacess file then you can create one. It's just a plain text file. Note that the filename begins with a period. Also note that some FTP software doesn't show filenames that start with a period unless you explicitly tell it to do so, and neither Mac OS X nor Windows like filenames that start with a period, either. If you're editing an existing .htaccess file, you can put the new commands anywhere in the file, either at the top or bottom, it doesn't matter. If you have an existing .htaccess file, back it up first before you start messing with it. Also, realize that any error in your .htaccess file will bring your whole site down. If you introduce a syntax error then visitors will see the dreaded "Internal server error" message when they try to access any page on your site. So every time you edit an .htaccess file, reload your site in a browser and make sure it still works okay. (If it doesn't work and you can't find the problem, then restore from your backup until you can.) Testing your site after every edit to .htaccess is not just something for newbies; I reload my site in a browser every time I edit an .htaccess file, no matter how simple the change. Every time. Whenever you do something that has the potential to bring your whole site down, then it behooves you to verify that you didn't. Redirecting all requests a new domainTo redirect all requests to a new domain, assuming the file structure on the new domain is identical to the old one, type:Redirect 301 / http://newdomain.com/ Redirecting a directory to a new domainLet's say part of your site has gotten really big and/or popular and now you want to move all that content to a new domain. It's easy to redirect all content from a directory on one site to a completely new domain:Redirect 301 /olddirectory http://newdomain.com/ Redirecting individual pagesTo redirect specific pages, either within a domain or to a new domain, you can use a bunch of 301's right after another:Redirect 301 /oldpage1.html http://domain.com/newpage1.html Redirect 301 /oldpage2.html http://domain.com/newpage2.html Redirect 301 /oldpage3.html http://domain.com/newpage3.html Advanced RedirectingThere's a more powerful -- and complicated -- way to redirect pages with Apache called mod rewrite which lets you redirect requests based on any combination of filename, directory name, extension, referrer, or even IP address attributes. The simple Redirect command above is all you need for basic redirects, but if you ever find yourself needing to redirect in a way that you can't do with the Redirect command, be sure to look into mod rewrite.
|
My favorite animation on the net:
|
|||||||||||||||||||
|