server { listen 80; server_name forum.mydomain.ru; root /var/www/html/forum; index index.php index.html index.htm; access_log /var/log/nginx/access.forum.mydomain.ru.log; error_log /var/log/nginx/error.forum.mydomain.ru.log; location ~ /(config\.php|common\.php|cache|files|images/avatars/upload|includes|store) { deny all; return 403; } location ~ /\.svn|/\.git|/\.ht { deny all; } location ~* \.(gif|jpe?g|png|css)$ { expires 30d; } location / { if (!-e $request_filename) { rewrite ^(.*)$ /app.php; } } location ~ \.php$ { try_files $uri $uri/ /app.php?$query_string; fastcgi_pass unix:/var/run/php5-fpm-forum.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }