How .htaccess works by Bally Chohan

February 26th, 2010

How .htaccess works by Bally Chohan

.htaccess is only a file, it can change settings on the servers and allow you to do many different things, the most popular being able to have your own custom 404 error pages. .htaccess isn’t difficult to use and is really just made up of a few simple instructions in a text file.

Options -Indexes  used to Stop A Directory Index From Being Shown

Deny/Allow Certian IP Addresses

deny from 000.000.000.000
allow from 000.000.000.000

If you want to deny everyone from accessing a directory, you can use:
deny from all

Redirection

One of the most useful functions of the .htaccess file is to redirect requests to different files, either on the same server, or on a completely different web site. It can be extremely useful if you change the name of one of your files but allow users to still find it. Another use (which I find very useful) is to redirect to a longer URL, for example in my newsletters I can use a very short URL for my affiliate links. The following can be done to redirect a specific file:

Redirect /location/from/root/file.ext http://www.othersite.com/new/file/location.xyz

Categories: PHP Tutorials

Leave a comment

Leave a comment