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++


2. Apache .htaccess Syntax, Tutorial


Share it

Syntax Apache .htaccess

.htaccess file syntax rules :

  1. one directive per line
    • maximum length of a line = 8192 characters
  2. one commented directive per line
    • the hash # character allows you to comment a directive → ignored directive
  3. backslash "\" as directive's last character → the directive continues onto the next line (line breaks)
  4. directives may be indent for clarity; blank lines and spaces before directives are ignored
  5. directives are case-insensitive
  6. arguments to directives are often case sensitive
  7. shell environment variables can be used, syntax is: ${VARIABLE}

Video demonstration Syntax Apache .htaccess

Syntax Apache .htaccess Tutorial

min video details
00:01 Syntax .htaccess Tutorial /Apache 2.2
00:10 one valid directive per line
00:16 one valid directive per 2 lines: possible if using the backslash "\" as directive's last character; the directive continues onto the next line
00:22 no other character or white space allowed between backslash and the end of the line
00:29 Test:
currently index.php delivered
00:34 if index.php is not available, the server will deliver index.html
00:39 making the index.php 'unavailable' by altering its name
00:44 Note: index.html displays the "It works!" text
00:49 Test result: ok
index.html delivered because index.php was not available → the directive split onto 2 lines works
01:02 one commented directive per line (this one does not apply, it is commented, see the hash character # at the beginning of the line)
01:08 blank lines between directives allowed (are ignored)
01:15 spaces before directives allowed (are ignored); directives may be indent for clarity
01:20 directives are case-insensitive
01:23 arguments to directives are often case sensitive

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