Here is my config file:
server {
listen 80;
server_name moule-a-manque.com;
access_log /var/log/nginx/myvps.com.access.log;
error_log /var/log/nginx/myvps.com.error.log;
client_max_body_size 4M;
client_body_buffer_size 128k;
expires off;
rewrite http://www.moule-a-manque.com http://moule-a-manque.com permanent;
location / {
root /var/www/mom;
index index.html index.php;
}
I assumed that should work but when i check at http://nibbler.silktide.com/reports/moule-a-manque.com it seems to say that the redirect is not working.
Am i doing this ocrrectly ? If so how can make sure the 301 redirect is indeed working
The rewrite directive in nginx only matches the path part of the url, not the hostname. It looks like you’re trying to force no-www, which is accomplished by using a second server{}:
In addition, it’s generally better to set your root outside of a location. Please see http://wiki.nginx.org/Pitfalls.