server { listen 80; server_name example.co.uk; index index.php index.html index.htm; autoindex on; root /var/www; rewrite \/blog\/feed$ /blog/rss.php; rewrite \/blog\/post\/(.*)$ /blog/viewpost.php?post=$1; location /dopost.php { auth_basic "Login to post"; auth_basic_user_file /var/www/.htpasswd; include /etc/nginx/fastcgi_params; fastcgi_pass unix:/var/run/php-fastcgi/php-fastcgi.socket; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/dopost.php; } location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass unix:/var/run/php-fastcgi/php-fastcgi.socket; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/$fastcgi_script_name; } }