I've got a tomcat 6 web app running with apache httpd as the front end. I'm using mod_proxy and mod_proxy_ajp to forward the requests to tomcat. My server is running ubuntu. Now I'm trying to use mod_rewrite to remove the leading www, so that my canonical website url is http://domain.com rather than http://www.domain.com
I've read a number of tutorials on using mod_rewrite, but I can't get any rewriting to work. I've tried putting the rewrite rule in an .htaccess file (after modifying my /etc/apache/sites-available/default file to set AllowOverride all). I've tried putting the rewrite rule in apache2.conf, httpd.conf, and rewrite.conf. I've tried all of these with rewrite logging turned on. The log file gets created, but apache has written nothing to it. I thought maybe mod_proxy was somehow preventing the rewrite rules from being used, so I tried disabling that as well...and I still get no rewrite, and nothing to the log.
At this point I have absolutely no idea what to try next. How do I go about troubleshooting why apache isn't using my rewrite rules?
For reference, here are my rewrite directives:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
RewriteLog "/var/log/apache2/rewrite.log"
RewriteLogLevel 3
</IfModule>
Edit: the responses below are helpful to my particular case, but probably not as helpful to the community-at-large as answers about how you troubleshoot apache directives in general. For example, is there a way to enable logging to the point where it would tell me which directives are being applied in which order as the request comes in?
Edit 2: I've gotten things to work now. My virtual hosts weren't quite set up right, and I also didn't quite have the rewrite regex right. Here is the final rewrite directives I got to work:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.domain\.com [NC]
RewriteRule ^(.*)$ http://domain.com$1 [L,R=301]
</IfModule>