Tag Archives: .htaccess

Password protection – htaccess

Create .htaccess file and paste the below given code into it .

AuthName “Member’s Area Name”
AuthUserFile /path/to/password/file/.htpasswd // Dont for got give a valid path of .htpasswd file
AuthType Basic
require valid-user

Create .htpasswd and gienterve the user name and encrypted password separated with ‘:’. The text would look like as follows

username:encryptedpassword
phpcodez:60h5w63DqQfls

NOTE : You can create the password using the link “http://www.4webhelp.net/us/password.php”

Hide PHP file extension

You can hide the php file extension using .htaccess so that you can confuse the spammers and hackers .

You can use “asp” file to work as a “php” file ie use the extension “asp” for yourr file instead of “php”.

You jsut need to cerate a .htaccess file and ad the code shown below

# Make PHP code look like asp or perl code
AddType application/x-httpd-php .asp

After this create file “comment.asp” and with php codes in it.

Then load the page “comment.asp”

File Caching

We can cache the file using htaccess so that we can improve
the perfomace of a website

General Format

<FilesMatch “.(Extenstion of the file to be cached)$”>
	Header set Cache-Control “max-age=cache time″
</FilesMatch>

Example

<FilesMatch “.(html|htm)$”>
	Header set Cache-Control “max-age=43200″
</FilesMatch