Posted by jasmineah on June 2, 2012 at 10:30pm
hi,
i have managed to get a site up but am experiencing problems with redirecting my domain from www.example.com to example.com.
my dns records are as follows
example.com A ipaddress
www.example.com A **ipaddress***
And my vhost server section is as follows
server_name example.com www.example.com;
The problem is when you visit www.example.com you get the text but no css, js or images but when you visit example.com all works well. i have also tried a redirect as suggested by Perusio in another discussion but this didn't help.
server {
server_name www.foobar.com;
return 301 http://foobar.com;
}
any ideas what the problem might be? thanks in advance.
Comments
Solved
All I had to do was put perusios solution at the top of my vhost before the server configs eg-
server {
Listen ipaddress;
server_name www.foobar.com;
return 301 http://foobar.com$request_uri;
}
server {
server_name foobar.com;
Listen ipadress;
root/etc/etc/;
Index etc etc;
.......
}