Yes - .htaccess file is the way by which you can hide real extension of your files from url.
There are many other things which you can do using .htaccess file like:
- Block specific IP to access your website.
- Allow specific IP to access your website.
- Stop specific folder to be shown
- Allow specific page to be displayed as an error page.
and many other things.
Have a look on this article: https://my.bluehost.com/cgi/help/htaccess