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


6. Tests .htaccess, Tutorial


Share it

Is it working ? .htaccess tests

The .htaccess file allows only valid Apache directives.

  1. Adding a non-valid directive:
    • if it crashes the server → .htaccess is working
    • if it doesn't crash the server, delivering the index file → .htaccess is NOT working
  2. Adding a valid directive:
    • the directive is honored → .htaccess is working
    • the directive is not honored → it depends on the output/error message

Valid vs Invalid Directives in .htaccess Tests:
different AccessFileName, wrong AllowOverride argument, module not loaded




DirectoryIndex directive tests .htaccess
Adding a valid directive and arguments

DirectoryIndex index.html index.php x.txt
Adding an INvalid directive and/or arguments

Directory Index index.html index.php x.txt
Apache v 2.2

AccessFileName .htaccess

AllowOverride All

mod_dir loaded
.htaccess works, directive is honored .htaccess works, directive NOT honored because invalid → 500 Server Error
Apache v 2.2

AccessFileName .z

AllowOverride All

mod_dir loaded
.htaccess ignored, directive ignored too .htaccess ignored, invalid directive ignored too
Apache v 2.2

AccessFileName .htaccess

AllowOverride Options

mod_dir loaded
.htaccess works but contains directive that cannot be overridden through .htaccess → directive not honored → 500 Server Error .htaccess works but contains invalid directive → 500 Server Error
Apache v 2.2

AccessFileName .htaccess

AllowOverride All

mod_dir not loaded
.htaccess works but directive unavailable in .htaccess because of unloaded module → 500 Server Error .htaccess works but contains invalid directive → 500 Server Error

Video demonstration Apache .htaccess Tests / 500 Server Error, Tutorial

Tests .htaccess Apache

min video details
00:01 .htaccess file Tests
00:04 When testing directives within a .htaccess file, 3 possible cases may arise:
- the directives are honored
- the directives are ignored
- the server throws an error
00:09 Next we will Test a valid and an invalid directive
00:14 DirectoryIndex is a valid Apache version 2.2.x directive
00:19 DirectoryIndex is also a directive that is in .htaccess
00:24 DirectoryIndex can be added within the .htaccess file if:
00:27 - if the AccessFileName is indeed .htaccess
00:32 - if the directive can be overridden through .htaccess (AllowOverride All or AllowOverride Indexes)
00:38 DirectoryIndex will work if the module that provides it, mod_dir, is loaded
00:50 Test:
00:53 the valid directive is honored, .htaccess is working
00:58 the invalid directive is not honored; .htaccess is working but contains invalid directive => 500 Server Error
01:05 If the AccessFileName is .z and not .htaccess but we continue to use the .htaccess name: => our .htaccess file is ignored and so is the directive within it
01:23 Test invalid directive: the .htaccess file is ignored
01:34 DirectoryIndex directive is listed under Indexes grouping of directives
In order to override it through .htaccess, AllowOverride either has the value All, either Indexes
01:46 If we specify the wrong grouping of directives (e.g. Options instead of Indexes) => the DirectoryIndex directive can't be overridden through .htaccess => 500 Server Error
02:03 Test invalid directive: invalid directives generate a 500 Server Error, if .htaccess works
02:17 If the module that provides the directive, mod_dir module, is not loaded (#) => a 500 Server Error
02:37 Test invalid directive: invalid directives always generate a 500 Server Error, if .htaccess works

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