Replies Back to Article

A tiny .htaccess tutorial

what about directory browsing
November 8, 2001 by Josh Crosby
How could you use this method to stop prowling eyes from looking into your directorys, (ie. /images/)
More Info
December 10, 2001 by Matt Jensen

Here is something I have archived, posted by Jeff Samborski somewhere:

If your on a Unix server you can use.htaccess and .htpasswd
The htaccess / .htpasswd method is very secure.

This method consists of  two text files work together to password protect
all of the files in a folder.

In your text editor create a file named .htaccess with the following
content:

AuthUserFile /relative/path/to/.htpasswd
AuthName "realm"
AuthType Basic

and a file named .htpasswd with the following content:

username:[encryptedPassword]

Upload .htaccess to the folder you want to protect (remember all files in
this folder will be password protected)
Upload .htpasswd to a different folder (its best to create a folder just for
this file)

Go to one of the PERL script archives and get one of the password management
scripts. This will create the encrypted passwords for the .htpasswd file and
allow you to easily manage, change and delete passwords.

--
Jeff Samborski
Lambert & Samborski Design
http://www.lamsam.com

More Info Again
December 10, 2001 by Matt Jensen
Page not found error
March 28, 2003 by Tracy Watson

The .htaccess is a great tool and I've successfully used it on both Unix and Linux servers mainly for the purposes of avoiding the UGLY 404 errors that inevitably crop up. 

I discovered a nifty piece of information last week in relation to the issue of MSIE displaying it's own 404 page.  To overcome this and to force MSIE to display your version of the 404 error (and the type I use are just basic HTML), you need to make your 404 file, larger than 512kb.  I'm not sure why this is, but it works.

Hope this can be of help to some of you out there.

Additional Use
April 22, 2004 by Michael Givens

You can also 'hide' the server technology you're using; instead of site visitors seeing you're running PHP, it appears that it's static HTML.

RE: Additional Use
April 22, 2004 by Michael Givens

RewriteEngine on

RewriteBase /

# parse out file extension, but remember the fact

RewriteRule ^(.*)\.html$ $1 [C,E=WasHTML:yes]

# rewrite to *.php if exists

RewriteCond %{REQUEST_FILENAME}.php -f

RewriteRule ^(.*)$ $1.php [S=1]

# else reverse the previous file extension rewrite

RewriteCond %{ENV:WasHTML} ^yes$

RewriteRule ^(.*)$ $1.html

RE: Additional Use
April 23, 2004 by Bob Costa
Sure. BUt it does not have to be that hard. The initial example intercepts all filenotfound requests, regardless of extension. Most of my URL's in my database are .html  or .htm extensions, but some are even oddball things like .xyz. The redirect script does not care, and what the user sees is the REQUESTED file name.  The PageNotFound.php is totally invisible to the site visitor.
might like this link
March 8, 2005 by Abdullah AL-Salal

nice article and thanx i never knew this file had uses like this.  after reading i did a small search on google and came up with this link thought you might like it :)

http://usertools.plus.net/tutorials/id/5

it's good to know there are people who care about sharing the knowledge they learn so keep it up.