server { #move the server_name 'www.' to rewrite #if you prefer www.example.com server_name www.example.com; rewrite ^ http://example.com$request_uri? permanent; } server { listen 80 default_server; #add 'www.' prefix if you prefer www.example.com server_name example.com; access_log /home/www/example.com/logs/access.log; error_log /home/www/example.com/logs/error.log; root /home/www/example.com/public_html/; index index.html index.htm index.php; location ~* \.(?:ico|css|js|gif|inc|txt|gz|xml|png|jpe?g)$ { expires max; add_header Pragma public; add_header Cache-Control "public, must-revalidate, proxy-revalidate"; } location / { try_files $uri $uri/ @rewrites; } location @rewrites { rewrite ^/([^/\.]+)/([^/]+)/([^/]+)/? /index.php?page=$1&id=$2&subpage=$3 last; rewrite ^/([^/\.]+)/([^/]+)/?$ /index.php?page=$1&id=$2 last; rewrite ^/([^/\.]+)/?$ /index.php?page=$1 last; } location /admin { } location /install { } location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; # The next two lines should go in your fastcgi_params fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } }