I intend to use htaccess to prevent hotlinking but if i upload the file to root, it blocks the hole site. Where should i put it?
Are you saying that you wish to prevent hot linking in some parts of the site and not others?
An .htaccess file sets configurations for the directory it is in, and all subdirectories of that directory which dont have overriding directives in their own .htaccess files, so you need to put the .htaccess file in the top level directory of each section of your site in which you wish to prevent hot linking.
It really sounds more like your directives to prevent hotlinking are wrong though, so you may wish to review them.