Apache, multi-language errors and mod-rewrite

In this quick article I'd like to comment a special case which is very much undocumented yet.

Apache in an XAMP environment (and probably in other environments too) has a very complex configuration. The httpd.conf includes a bunch of further config files. That part of the config currently looks like:

# XAMPP specific settings
Include "conf/extra/httpd-xampp.conf"
 
# Perl settings
Include "conf/extra/perl.conf"
 
# Server-pool management (MPM specific)
Include "conf/extra/httpd-mpm.conf"
 
# Multi-language error messages
Include "conf/extra/httpd-multilang-errordoc.conf"
 
# Fancy directory listings
Include "conf/extra/httpd-autoindex.conf"
 
# Language settings
Include "conf/extra/httpd-languages.conf"
 
# User home directories
Include "conf/extra/httpd-userdir.conf"
 
# Real-time info on requests and configuration
Include "conf/extra/httpd-info.conf"
 
# Virtual hosts
Include "conf/extra/httpd-vhosts.conf"
 
# Distributed authoring and versioning (WebDAV)
Include "conf/extra/httpd-dav.conf"
 
# Implements a proxy/gateway for Apache.
Include "conf/extra/httpd-proxy.conf"
 
# Various default settings
Include "conf/extra/httpd-default.conf"
 
# Secure (SSL/TLS) connections
Include "conf/extra/httpd-ssl.conf"

All of them are enabled by default.

In one of my projects, I make extensive usage of URL rewriting. The concept is simple: I take the whole query string and pass it into my code as the $url parameter (e.g. example.com/index.php?url=QUERY_STRING). This way the rewriting is very simple and all I have to do for new paths is to analyse the incoming $url parameter.

When implementing an error module with a path like example.com/error/accessDenied for denying access to certain parts, apache just didn't enter my code, but instead told me it's an 404 (file not found). Of course the file was not found. It was a pure virtual (rewritten) path. I shelved this problem, but today I found a solution. Actually I was just about to asked my favourite SEO community, as they are really focussed on rewriting. However, I found the solution myself while trying to describe the issue.

The problem was one of the above includes. Apache has a folder for multilanguage error messages. Who would ever need them? It's a stupid idea to translate server level errors to local languages of course, and doing so introduces new side-effects.

The included apache config file creates an alias for /error/ redirecting the requests to "C:/xampp/apache/error/". Stupid as that is, this way the folder-specific .htaccess is circumvented and Apache absolutely correctly can't find my virtual file /error/accessDenied.

So, if you are rewriting paths and Apache seems to ignore that in certain situations, go on by:

  • Looking into your Apache logs. You'll find error log entries telling you what path Apache tries to load.
  • Search through the apache.conf for aliases.
  • Don't forget to search through the includes.

Finally, just comment out all that stuff you don't need. Comment our anything you don't need. This will help avoiding such ugly issues in the future. And always keep backups!™

Hope this helps.

Yours
Trashy