mbchowdari
Joined: 08 May 2008 Posts: 52
|
Posted: Thu Aug 13, 2009 7:30 am Post subject: About .htaccess |
|
|
An .htaccess is a simple ASCII file, such as you would create through a text editor like Notepad or SimpleText.
.htaccess is the file extension. It is not file.htaccess or somepage.htaccess, it is simply named .htaccess.
.htaccess files must be uploaded as ASCII mode only. You may need to CHMODthe htaccess file to 644 or (rw-r--r--). This makes the file usable by the server, but prevents it from being read by a browser. (For example, if you have password protected directories, if a browser can read the htaccess file, then they can get the location of the authentication file and then the list to get full access to any portion that you previously had protected.
.htaccess files use the default filename “.htaccess” but any UNIX-style file name can be specified from the main server config using the Access Filename directive. The file isn’t .htaccess.txt, its literally just named .htaccess.
1) Error Documents:
In order to specify your own customized error documents, you simply need to add the following command, on one line, within your htaccess file:
ErrorDocument code /directory/filename.ext
or
ErrorDocument 404 /errors/notfound.html
This would cause any error code resulting in 404 to be forward to yoursite.com/errors/notfound.html
ErrorDocument 500 /errors/internalerror.html
the htaccess file would look like the following (note: each command is on its own line):
ErrorDocument 400 /errors/badrequest.html
ErrorDocument 401 /errors/authreqd.html
ErrorDocument 403 /errors/forbid.html
ErrorDocument 404 /errors/notfound.html
ErrorDocument 500 /errors/serverr.html
2) Password Protection:
Password Protection to your sites to prevent some users to access our site. So you have to to provide password protection for your sites. So create a file called “.htpasswd” with your login details like user name and password to protect.
In the htpasswd file, you place the username and password (which is encrypted) for those whom you want to have access.
For example,
wsabstract:y4E7Ep8e7EYV
Here wsabstract is the username and y4E7Ep8e7EYV is the password
Notice that it is UserName first, followed by the Password. There is a handy-dandy-tool available for you to easily encrypt the password into the proper encoding for use in the httpasswd file.
Create a new htaccess file and place the following code in it:
AuthUserFile /usr/local/you/safedir/.htpasswd
AuthGroupFile /dev/null
AuthName EnterPassword
AuthType Basic
require user wsabstract
The first line is the full server path to your htpasswd file. |
|