views:

52

answers:

3

hello im having problem with my site when i type http://example.com it works fine but when i type http://www.example.com it displays page cannot be found ,

what is the problem i couldnot find , i tried .htaccess redirection also

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com [nc]
RewriteRule (.*) example.com/$1 [R=301,L]

it is not working

any help will be appreciated

+3  A: 

If you're redirecting to a different website you have to specify 'http://' at the front, otherwise Apache it will interpret it as a file on the server.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com [nc]
RewriteRule (.*) http://example.com/$1 [R=301,L]
animuson
also change [nc] to [NC]
Nir Levy
+1  A: 

Check that you have the alias for www set in the apache vhost file

<VirtualHost *>
..
ServerName www.example.com
ServerAlias example.com
...
</VirtualHost>

Also remember to restart Apache after each change.

Benjamin Ortuzar
A: 

Have you set up DNS aliases for both adresses? Do they point to the same IP? Depending on your ISP it may take some time before any changes work for you.

Kagee