.htaccess facts for kids
'.htaccess' is a special computer file that helps control how a website server works. Think of it like a set of instructions for the server. These files can do many useful things, like creating custom error pages when something goes wrong on a website, or stopping people from directly linking to your pictures on their own websites. This direct linking is called hot-linking, and it can cost the website owner money because it uses up their internet data without visitors actually coming to their site.
Contents
Stopping Hot-Linking
One of the main uses for a .htaccess file is to prevent hot-linking. When you put a .htaccess file on your website, it can stop other people from using the direct web address (called a URL) of your images. For example, if your picture is at www.yourwebsite.com/picture.jpg, the .htaccess file can prevent someone else from showing that picture on their own website using your link.
Instead of showing your picture, the server can be told to do something else. It could show a special message instead of the image, or it could even send the person to an error page. This helps website owners save money and control how their content is used.
How .htaccess Changes Web Addresses
.htaccess files are also great for making web addresses look much neater and easier to understand. Many websites use complicated URLs by default, but .htaccess can change them into something simpler.
Making MediaWiki URLs Friendly
By default, a website built with MediaWiki (which is the software Wikipedia uses) might have long web addresses like http://www.example.org/index.php/Main_Page. But with a few changes in the .htaccess file, the address can become much shorter and friendlier, like http://www.example.org/wiki/Main_Page. This makes the website look more professional and is easier for people to remember.
Making WordPress URLs Friendly
Similarly, if you have a WordPress blog, the default web addresses for your posts might look like http://www.example.org/?p=123. This isn't very descriptive. By using .htaccess, you can change these addresses (often called permalinks) to something much clearer, like http://www.example.org/2010/06/postname. This helps visitors know what the page is about just by looking at the address.