Sunday, May 19, 2013

.htaccess Basic

What is .htaccess ? 

htaccess is a configuration file for use on web servers running the Apache Web Server software.

abbreviation from hypertext access

When a .htaccess file is placed in a directory  of apache then the .htaccess file is detected and executed by the Apache Web Server software on prioirty. 

.htaccess files can be used to alter the configuration of the Apache Web Server software to enable/disable additional functionality and features that the Apache Web Server software has to offer. These facilities include basic redirect functionality, for instance if a 404 file not found error occurs, or for more advanced functions such as content password protection or image hot link prevention.

'.htaccess' is the filename in full, it is not a file extension. For instance, you would not create a file called, 'file.htaccess', it is simply called, '.htaccess'. This file will take effect when placed in any directory which is then in turn loaded via the Apache Web Server software. The file will take effect over the entire directory it is placed in and all files and subdirectories within the specified directory.

This file is inaccessible through web.

You can create a .htaccess file using any good text editor such as TextPad, UltraEdit, Microsoft WordPad and similar (you cannot use Microsoft NotePad). 

.htaccess is mainly used to rewrite urls 

.htaccess example #1




   RewriteEngine on
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]


it redirects every request to app/webroot


this file can be used to allow/deny access from specific ip



.htaccess example #2




order allow deny
deny from all
allow from 192.126.12.199


How to test it?

you can test ur .htaccess file here

http://htaccess.madewithlove.be/



No comments:

Post a Comment