I have a website that doesn\'t seem to redirect from non-www to www.
My Apache configuration is as follows:
RewriteEngine On
### re-direct t
Do not always use Redirect permanent
(or why it may cause issues in future)
If there is a chance that you will add subdomains later, do not use redirect permanent
.
Because if a client has used a subdomain that wasn't registred as VirtualHost
he may also never reach this subdomain even when it is registred later.
redirect permanent
sends an HTTP 301 Moved Permanently
to the client (browser) and a lot of them cache this response for ever (until cache is cleared [manually]). So using that subdomain will always autoredirect to www.*** without requesting the server again.
see How long do browsers cache HTTP 301s?
So just use Redirect
ServerName example.com
Redirect / http://www.example.com/
Apache.org - When not to use mod_rewrite
Apache.org - Canonical Hostnames