Setup: Apache 2.2 (Windows, win32).
httpd.conf snippets:
Alias /custom /var/www/custom
DirectoryIndex index.html
<Location /custom>
SetHandler custom_handler
DirectoryIndex index.html
</Location>
<Directory /var/www>
Allow From all
Options +Indexes
AllowOverride all
DirectoryIndex index.html
</Directory>
Also:
- mod_dir, mod_rewrite activated
- index.html present in /var/www/custom
- server process UID may read all files/directories in /var/www
- Apache service listens at all interfaces
- custom handler processes certain URLs within Location path, other are served from file system; index.html is processed as if no handler is present
Problems:
- rewriting URLs starting with the Location path are not working (no errors reported)
- when trying to serve http://server/custom (without closing slash), the following happens:
- Apache redirects to http://ServerName/custom/ (to ServerName directive value)
- "Attempt to serve directory" is written to error log for /var/www/custom/
- 404 error is returned
How the above can be handled? The following is requried:
- serve /var/www/custom/index.html when http://server/custom is entered, or
rewrite certain URLs, like
RewriteRule ^custom/$ /custom/index.html [L,R]
The above rewrite rule doesn't work, wherever it's placed (in or outside Location)