location / { if ($http_host ~* "^www\.(.+)$"){ rewrite ^(.*)$ http://%1/$1 redirect; } if (!-e $request_filename){ rewrite ^(.*)$ /index.php; } index index.htm index.html index.php; }