Hello
This is essentially a re-post of
a Webmaster World post that has gone unanswered for 36+ hours. Maybe the Debian-specific nature of the question put off answerers.
After much experimentation, I have assembled a very basic test of rewriting but it doesn't seem to do anything.
On a Debian Squeeze system, I re-initialised Apache by:
Code:
# aptitude purge apache2 apache2-utils apache2.2-bin apache2.2-common
# rm -fr /etc/apache2 /var/www /var/log/apache2
# aptitude -y install \
apache2 apache2-mpm-prefork \
libapache2-mod-perl2 libapache2-mod-php5 \
libapache2-mod-python libapache2-reload-perl \
nagios3 nagios3-cgi
# a2enmod rewrite
Note: the installation command also restores packages that were removed during the purge because they depend on the re-initialised Apache packages.
Created /etc/apache2/conf.d/rewrite_tests:
Code:
LogLevel debug
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" \"%e\"" combined
Options All
RewriteEngine On
RewriteLog /var/log/apache2/rewrite.log
RewriteLogLevel 7
RewriteRule ^ - [env=FOO:BAR]
RewriteRule ^(.*)$ http://www.linuxquestions.org/ [L,R,NE]
Notes:
- The LogFormat re-definition adds envar reporting.
- The first RewriteRule only sets envar FOO.
- The second RewriteRule is based on the example given in the Apache RewriteRule documentation in the Canonical Hostnames section, for the port 80 example.
After restarting Apache:
- /var/log/apache2/rewrite.log is created.
- Browsing http://<server ID by name or IP address> displays the as-installed /var/www/index.html, not Linux Questions as intended. Then ...
- /var/log/apache2/access.log shows "-" in the %e field, so the FOO envar was not set.
- /var/log/apache2/rewrite.log is empty.
- /var/log/apache2/error.log shows no errors, only startup messages.
Does the evidence support the theory that rewriting is not doing anything?
Could /etc/apache2/conf.d/rewrite_tests be better devised to test basic rewriting functionality?
How can rewriting functionality be enabled?
Best
Charles