mod_rewrite adding documentroot to url

The following rewrite redirects http://example.com/ to http://example.com/www/www.example.com/public_html instead of http://www.example.com/. /www/www.example.com/public_html is the DocumentRoot.

# Rewrite Rules for Example
RewriteEngine On
RewriteBase /

# Redirect from example.com to www.example.com
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

This redirect is in a <VirtualHost *:80> with the settings:

ServerName example.com
ServerAlias www.example.com
ServerAdmin [email protected]

Options +FollowSymLinks
DocumentRoot /www/www.example.com/public_html

and the rewrite is inside <Directory />

Any ideas why it would do this? I looked into the Apache manual and it says that using ${HTTP_HOST} in your RewriteCond will add the host to the RewriteRule instead of just the URL-Path. Well this is a VERY common rewrite, and I've never seen this happen before.


Solution 1:

The problem was <Directory />. Once I updated it to <Directory /www/www.example.com/public_html> it worked just fine.