server { listen 80; server_name *.leaderbin.com; if ($host ~* "^(.+)\.leaderbin\.com$") { rewrite ^(.*)$ http://leaderbin.com$1 permanent; } } server { listen 80; server_name local.leaderbin.com leaderbin.com; access_log /var/log/nginx/leaderbin.com.access.log; error_log /var/log/nginx/leaderbin.com.error.log; root /var/www/leaderbin.com/public; rewrite_log on; # Rewrites static content with an appended timestamp location ~ ^/(.+)\.(\d+)\.(css|js|gif|png|jpg|jpeg)$ { rewrite ^/(.+)\.(\d+)\.(css|js|gif|png|jpg|jpeg)$ /$1.$3 break; expires max; } location / { index index.php; # Strips the trailing slash rewrite ^/(.*)/$ /$1 permanent; # If file exists return it right away if (-f $request_filename) { expires max; break; } # Accommodate UIDs at the end of the URI rewrite ^/(.+)/(\d+)$ /index.php?request=$1&uid=$2 last; # and the rest rewrite ^/(.+)$ /index.php?request=$1 last; } location ~ \.php$ { try_files $uri =404; include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/leaderbin.com/public$fastcgi_script_name; } }