Advertisement
matriphe

Nginx config for Wordpress multi site subdirectories

Jan 31st, 2013
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. server {
  2. listen 80;
  3. server_name your.domain.name;
  4.  
  5. #charset koi8-r;
  6.  
  7. access_log /path/to/log/access.log main;
  8. error_log /path/to/error/log/error.log;
  9.  
  10. root /path/to/directory/root;
  11. index index.php index.html;
  12.  
  13. # Add trailing slash to */wp-admin requests.
  14. rewrite /wp-admin$ $scheme://$host$uri/ permanent;
  15.  
  16. # Add trailing slash to */username requests
  17. rewrite ^/[_0-9a-zA-Z-]+$ $scheme://$host$uri/ permanent;
  18.  
  19. # Pass uploaded files to wp-includes/ms-files.php.
  20. rewrite /files/$ /index.php last;
  21.  
  22. if ($uri !~ wp-content/plugins) {
  23. rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last;
  24. }
  25.  
  26. # Rewrite multisite '.../wp-.*' and '.../*.php'.
  27. if (!-e $request_filename) {
  28.  
  29. rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
  30. rewrite ^/[_0-9a-zA-Z-]+.*(/wp-admin/.*\.php)$ $1 last;
  31. rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
  32.  
  33. }
  34.  
  35. location / {
  36. try_files $uri $uri/ /index.php;
  37.  
  38. if (-e $request_filename) {
  39. break;
  40. }
  41.  
  42. if (!-e $request_filename) {
  43. rewrite ^(.*)$ /index.php?q=$1 last;
  44. }
  45. }
  46.  
  47. error_page 404 /404.html;
  48. location = /404.html {
  49. root /usr/share/nginx/html;
  50. }
  51.  
  52. error_page 500 502 503 504 /50x.html;
  53. location = /50x.html {
  54. root /usr/share/nginx/html;
  55. }
  56.  
  57. location ~ \.php$ {
  58. #root html;
  59. fastcgi_pass 127.0.0.1:9000;
  60. fastcgi_index index.php;
  61. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  62. include fastcgi_params;
  63. }
  64.  
  65. location ~ /\.ht {
  66. deny all;
  67. }
  68.  
  69. location /favicon.ico { access_log off; error_log off; }
  70. location /robots.txt { access_log off; error_log off; }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement