Created
December 2, 2018 21:57
-
-
Save msalahat/52dd0ba5061116e96b3e4d887634aa26 to your computer and use it in GitHub Desktop.
wordpress multisite nginx rewrite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location / { | |
root /var/www/example.com/wordpress; | |
index index.html index.htm index.php; | |
rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last; | |
if (!-e $request_filename) { | |
rewrite ^.+/?(/wp-.*) $1 last; | |
rewrite ^.+/?(/.*\.php)$ $1 last; | |
rewrite ^(.+)$ /index.php?q=$1 last; | |
} | |
} | |
location ~* ^.+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$ | |
{ | |
root /var/www/example.com/wordpress; | |
rewrite ^/.*(/wp-.*/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last; | |
rewrite ^.*/files/(.*(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$/wp-includes/ms-files.php?file=$1 last; | |
expires 30d; | |
break; | |
} | |
location ~ wp\-.*\.php|wp\-admin|\.php$ { | |
root /var/www/example.com/wordpress; | |
include /etc/nginx/fastcgi_params; | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root /usr/local/www/playground/php/wordpress/; | |
index index.php index.html; | |
rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last; | |
rewrite ^(.*)?(/wp-(content|admin|includes)/.*) $2 last; | |
rewrite ^(.*)?(/wp-.*\.php)$ $2 last; | |
location / { | |
index index.php; | |
if (!-e $request_filename) { | |
rewrite ^.+?(/wp-.*) $1 last; | |
rewrite ^.+?(/.*\.php)$ $1 last; | |
rewrite ^ /index.php last; | |
} | |
} | |
location ~ \.php$ { | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME /$document_root$fastcgi_script_name; | |
include /usr/local/etc/nginx/fastcgi_params; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment