.htaccess is a configuration file which is used to restrict users from accessing your private pages. .htaccess is a system file that runs on Apache servers, and can contain all sorts of control information. It is principally used to manage redirects and do to set custom error pages. You can’t access .htaccess, it just sits there doing its thing.
robots.txt is a text file that used by any websites owner to give instructions about their site to web robots (mostly search engine spiders) of any sections of your website that you don’t want them to access – they can decide whether or not to act on these suggestions. Anyone can read a site’s robots.txt file if they want to, and it doesn’t force anything to happen. robots.txt tells the search engines which URLs should not be indexed.
.htaccess – This file can achieve many functions, such as
– Ban a particular IP or User-agent.
– Redirect URLs
– Rewrite URLs with SE friendly names etc