Possible Duplicate:
apache redirect from non www to www
Is it possible to configure DNS to add www. prefix to the domain name?
Possible Duplicate:
apache redirect from non www to www
Is it possible to configure DNS to add www. prefix to the domain name?
RewriteEngine On RewriteCond %{HTTP_HOST} !^www.normalurl.com$ [NC] RewriteRule ^(.*)$ http://www.normalurl.com/$1 [L,R]
Nope. You have to configure the webserver at yourdomain.com
to redirect to www.yourdomain.com
.
For example, on apache, you can use this configuration (using mod_alias
):
<VirtualHost *:80>
ServerName www.yourdomain.com
## Actual configuration here...
</VirtualHost>
<VirtualHost *:80>
## redirect non-www to www
ServerName www.yourdomain.com
ServerAlias yourdomain.com
RedirectMatch permanent ^(.*) http://www.yourdomain.com$1
</VirtualHost>
A DNS response contains a mapping of a domain name to an IP address. While you could alias example.net to www.example.net with a CNAME record, this would not be visible for the user.
Most likely, you want to configure your web server to send an HTTP 301 redirect to the correct URL.