Replies Back to Article
A tiny .htaccess tutorial
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
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.
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.
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
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.