W3-Video WEB Tutorials

w3-video.com is a Free eLearning Website with over 500 video tutorials on HTML5, XAMPP, .htaccess, Firefox, Notepad++

.htaccess Tutorial

Home HTML5 XAMPP .htaccess Firefox Notepad++


1. Apache .htaccess Intro, Tutorial


Share it

Intro Apache .htaccess

The .htaccess file:

  1. contains configuration directives
  2. allows you to override configuration directives per directory level
  3. scope: directory level and its subtree (placed in a directory, the directives apply to that directory and all its subdirectories)

.htaccess = server manipulation

Any valid directive placed in a .htaccess file can be placed in the server's core configuration file (httpd.conf).

Warning

Using the .htaccess files slows down your Apache http server.
Use it ONLY WHEN you DON'T have access to the main server configuration file (usually httpd.conf): e.g. shared hosting environements

Video demonstration Intro .htaccess

Intro .htaccess Tutorial

min video details
00:01 Intro .htaccess Tutorial /Apache 2.2
00:05 1. Create the file:
00:05 The .htaccess file ca be created using a free text editor like Notepd++
00:13 it contains valid directives
00:18 2. Save the file:
00:18 it must be saved with the AccessFileName: by deault it's: .htaccess
00:30 if the AccessFileName is for example (.zzz), you'll save the file with the name .zzz
00:42 3. Usage:
00:42 The .htaccess file allows you to make server configuration changes (set, override directives..) on a per-directory basis
00:51 example: lets override the 'Allow from all' directive (httpd.conf) to 'Deny from all' (.htaccess)
00:59 the 'Allow from all' directive (httpd.conf) allows everyone's access to the server
01:04 while 'Deny from all' (.htaccess) will override the 'Allow from all' directive (httpd.conf), denying everyone's access to the server
01:12 4. Effect:
01:12 the .htaccess file takes effect once uploaded on server in the desired directory
01:17 'Deny from all' directive (.htaccess) denies everyone's access to the server
01:21 5. Scope:
01:21 placed in a directory (htdocs in our case), the directives apply to that directory and all its subdirectories: e.g. dirA, images, ...
01:30 Note: the access to dirA is forbidden (403)
01:34 when placed only inside the dirA, the directives will apply to dirA and all its subdirectories (dirB), and will not apply to htdocs directory
01:42 the access to dirA, dirB is forbidden, while the access to localhost (htdocs) is allowed
01:50 6. Occurrences:
01:50 1 .htaccess file per directory allowed
02:00 7. Observations:
02:00 any valid directive placed in a htaccess file can be placed inside the server's core configuration file (httpd.conf)
02:06 if you don't have access to the server's core configuration file (usually this happens in shared hosting environements), then you'll use the .htaccess file to manipulate the server, this with a small performance cost

For more information about the htaccess file, please see the spec: apache.org