site not working with url www
hello im having problem with my site when i type http:/开发者_如何学C/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
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]
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.
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.
精彩评论