Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Nginx Config File for WordPress MultiSite (3/3)

By: a guest on Dec 27th, 2012  |  syntax: None  |  size: 2.39 KB  |  hits: 24  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # WordPress multisite subdirectory rules.
  2. # Designed to be included in any server {} block.
  3.  
  4. # This order might seem weird - this is attempted to match last if rules below fail.
  5. # http://wiki.nginx.org/HttpCoreModule
  6. location / {
  7.         try_files $uri $uri/ /index.php?$args;
  8. }
  9.  
  10. # Add trailing slash to */wp-admin requests.
  11. rewrite /wp-admin$ $scheme://$host$uri/ permanent;
  12.  
  13. # Directives to send expires headers and turn off 404 error logging.
  14. location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
  15.         expires 24h;
  16.         log_not_found off;
  17. }
  18.  
  19. # Pass uploaded files to wp-includes/ms-files.php.
  20. rewrite /files/$ /index.php last;
  21.  
  22. # For multisite:  Use a caching plugin/script that creates symlinks to the correct subdirectory structure to get s\
  23. ome performance gains.
  24. set $cachetest "$document_root/wp-content/cache/ms-filemap/${host}${uri}";
  25. if ($uri ~ /$) {
  26.         set $cachetest "";
  27. }
  28. if (-f $cachetest) {
  29.         # Rewrites the URI and stops rewrite processing so it doesn't start over and attempt to pass it to the nex\
  30. t rule.
  31.         rewrite ^ /wp-content/cache/ms-filemap/${host}${uri} break;
  32. }
  33.  
  34. if ($uri !~ wp-content/plugins) {
  35.         rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last;
  36. }
  37.  
  38. # Uncomment one of the lines below for the appropriate caching plugin (if used).
  39. # include global/wordpress-ms-subdir-wp-super-cache.conf;
  40. # include global/wordpress-ms-subdir-w3-total-cache.conf;
  41.  
  42. # Rewrite multisite '.../wp-.*' and '.../*.php'.
  43. if (!-e $request_filename) {
  44.         rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
  45.         rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
  46. }
  47.  
  48. # Pass all .php files onto a php-fpm/php-fcgi server.
  49. location ~ \.php$ {
  50.         # Zero-day exploit defense.
  51.         # http://forum.nginx.org/read.php?2,88845,page=3
  52.         # Won't work properly (404 error) if the file is not stored on this server, which is entirely possible wit\
  53. h php-fpm/php-fcgi.
  54.         # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine.  And then cross your\
  55.  fingers that you won't get hacked.
  56.         try_files $uri =404;
  57.  
  58.         fastcgi_split_path_info ^(.+\.php)(/.+)$;
  59.         include fastcgi_params;
  60.         fastcgi_index index.php;
  61.         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  62. #       fastcgi_intercept_errors on;
  63. #       fastcgi_pass php;
  64.         fastcgi_pass unix:/var/run/php5-fpm-tpnet.sock;
  65. }