Rewriting www to non-www is not working.
The domain.com
URL works but www.domain.com
gives the following error "Problem loading page - Mozilla Firefox - Server not found".
I've cleared FF Cache, etc.. IE, says, Internet Explorer cannot display the webpage.
I tried the following configuration and all other rewrite examples from other tutorials, including the nginx documentation. Instead of restarting or reloading nginx, (nothing to chance) I rebooted system. My setup is a base install of Debian Lenny, nginx dependencies, and apt-get install nginx; that's it. Very simple test server. I created a domain.com file in sites-available and did a symbolic link to sites-enabled. Here is my domain.com config file (done in accordance with best practice, and followed the pitfall documentation section of nginx):
server {
server_name www.domain.com;
rewrite ^ $scheme://domain.com$request_uri permanent;
}
server {
server_name domain.com;
location / {
root /srv/www/sites/domain.com;
}
}
What am I missing here? I also tried with nginx-0.8.54; compiled the latest stable version. I tried on two different physical servers; tried on vmware VMs; and tried accessing from remote computer. The rewrite according to everyone's tutorial seems to work, but for me it doesn't. I put Apache servers together no prob, but I keep banging my head against the desk on nginx.
Also, I did a local test and edited C:\WINDOWS\system32\drivers\etc\hosts to point to domain.com and www.domain.com; still doesn't work.
Anyone have a suggestion? Or is this a big secret? Like some secret rewrite module enabler?
Best Answer
Your etc\hosts reads 4 wwww. Change it to 3 www and it will work. It sounds like maybe you need to get some rest. :)