.htaccess basics
.htaccess is a file for the webserver Apache. It allows you to set passwords on folders and make custom error pages, e.g 404, and many other things.
If you don't run your own server, maybe you aren't allowed to use .htaccess. But follow the instructions below to see if it works.
To make a .htaccess file, simply open up any texteditor, and enter your commands, each should be on a seperate line. When saving your file, enter .htaccess as the file name and choose 'All Files' as file type, else the filename might be .htaccess.txt or something.
Now to test if .htaccess files works on your server, try making a custom 404 page.
When uploading your .htaccess file through ftp, make sure you are in ASCII mode, not binary. Some web servers will hide your .htaccess file, so if your FTP client don't show hidden files you can't see it. But of course you can make your FTP client show hidden files, read this how to fix it.
When you have uploaded your .htaccess file, and if you added some lines in it for a custom 404 page, now try to go to http://yourpage/wljrkklr.html or something, if you see your custom 404 document you can use .htaccess on your server.
But if it doesn't work, and you have access to Apaches config, which should be httpd.conf and it should be located somewhere in the Apache folder, you can easily fix it. Make sure you have these lines in the config file:
AllowOverride All
and
AccessFileName .htaccess
After you have changed this, the server needs to be restarted in order for the changes to apply. Both of these lines are actually the default. But maybe they are changed or aren't there at all for some reason. Read more about AllowOverride and AccessFileName in the Apache documentation.
When the .htaccess file is placed in the root directory, it will also affect all subdirectories, and also override other .htaccess files in the subdirectories. If you place it in a subdirectory it will affect all the files of that directory.
To prevent others from viewing the contents of your .htaccess file, and .htpasswd if you got any, place the following in the file.
<Files ~ "^\.ht">
Order allow,deny
Deny from all
</Files>
But this might already be in Apaches config file httpd.conf. Anyway to check if it is, you could enter the url to you .htaccess. If you aren't allowed to see the contents of the file you get 403 Forbidden error. And it's safe to use .htaccess files :)