You can create a .htaccess file on your local computer or on the server.
On your computer:Windows: Using Notepad save the file as .htaccess
Mac OS X: Using TextEdit save the file as ".htaccess"
Note: If you save the file as .htaccess it will be hidden and you will not be able to see it in the Finder.
Using your preferred FTP client upload the file to the server. The .htaccess file will need to be in the folder where your site is located, typically the public_html folder.
On the server
- Login to your cPanel Account
- Click the File Manager icon, located in the Files section.
- From the File Manager popup choose "Choose Hidden Files (dotfiles)."
Note: If you do not see this popup you will need to click the "reset all interface settings" link at the bottom of the cPanel page.
- From the File Manager popup choose the folder you would like to open, most often the "Web Root (public_html/www)"
- Click the Go button.
Note: If you are in the File Manager already you can add &showhidden=1 to the end of the URL.
- Click the New File icon to create a new file and name it .htaccess
Alternative Index Files
You may not always want to use index.htm or index.html as your index file for a directory, for example, if you are using PHP files in your site, you may want index.php to be the index file for a directory. You are not limited to 'index' files though. Using .htaccess you can set foofoo.blah to be your index file if you want to!
Alternate index files are entered in a list. The server will work from left to right, checking to see if each file exists, if none of them exist it will display a directory listing (unless you have turned this off).