Skip to content

Instantly share code, notes, and snippets.

@mpeshev
Created September 20, 2015 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpeshev/6b8979b561cf6b9cc880 to your computer and use it in GitHub Desktop.
Save mpeshev/6b8979b561cf6b9cc880 to your computer and use it in GitHub Desktop.
nginx subfolder WordPress config
server {
listen 80;
server_name maindomain.com/forums;
root /var/www/maindomain.com/forums;
index index.php index.html index.htm;
location / {
index index.html index.php;
try_files $uri $uri/ /index.php?q=$uri&$args;
#try_files $uri $uri/ /index.php?q=$uri&$args;
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 24h;
log_not_found off;
}
if ($uri !~ wp-content/plugins) {
rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last;
}
if (!-e $request_filename) {
rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
rewrite ^/[_0-9a-zA-Z-]+.*(/wp-admin/.*\.php)$ $1 last;
rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
}
location ~ \.php$ {
try_files $uri /index.php;
autoindex on;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
#fastcgi_pass_header Set-Cookie;
include fastcgi_params;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment