- Code: Select all
<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!