I'm currently redirecting all non-www traffic to the www version -- the RewriteRules below work fine. However, if I map a URL using the Alias directive (such as /images), I noticed that the rewrite rules take no effect; the /images URL is accessible with both the www and non-www version instead of redirecting to the www version. Here's my relevant Apache configuration:
Code:
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
<Directory "/var/www/example/public">
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
</Directory>
Alias /images /var/www/images
</VirtualHost>
With the above code, all relevant URLs redirect properly to the www version,
except when using the /images alias. So the /images alias is available from both of these URLs:
http://example.com/images/http://www.example.com/images/The non-www version does not redirect to the www version, but all other URLs and links redirect perfectly. Does anyone know how to fix this? I read about the PT flag but can't seem to get it to work in this context.
Thanks for the help!