我在名为/ WordPressDemo的子目录中安装了Wordpress。 有一个名为demo.example.com的域名,文件为root /表示您需要输入demo.example.com/WordPressDemo才能访问WordPress。
我使用nGINX会导致很多麻烦,我设法让基本链接(例如固定链接)工作,因此多站点本身可以工作,唯一的问题是它从错误的路径请求静态数据。
示例:
它要求: http://demo.example.com/WordPressDemo/MULTISITE-NAME/wp-includes/js/jquery/jquery.js?ver=1.11
但应该请求
http://demo.example.com/WordPressDemo/wp-includes/js/jquery/jquery.js?ver=1.11
我当前的nginx指令:
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^/WordPressDemo(/[^/]+)?(/wp-.*) /WordPressDemo$2 last;
rewrite ^/WordPressDemo(/[^/]+)?(/.*\.php)$ /WordPressDemo$2 last;
}
location / {
try_files $uri $uri/ /WordPressDemo/index.php?$args ;
}
location ~ \.php$ {
try_files $uri /WordPressDemo/index.php;
include fcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off; log_not_found off; expires max;
}
答案 0 :(得分:-1)
你有没有看过the Wordpress codex?
无论如何,您可能有兴趣修改此代码:
# WordPress multisite subdirectory rules.
# Designed to be included in any server {} block.
# This order might seem weird - this is attempted to match last if rules below fail.
# http://wiki.nginx.org/HttpCoreModule
location / {
index index.php;
try_files $uri $uri/ /index.php?$args;
}
# Directives to send expires headers and turn off 404 error logging.
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 24h;
log_not_found off;
}
location ~ ^/[_0-9a-zA-Z-]+/files/(.*)$ {
try_files /sites/$blogid/files/$2 /wp-includes/ms-files.php?file=$2 ;
access_log off; log_not_found off; expires max;
}
#avoid php readfile()
location ^~ /sites {
internal;
alias /var/www/mu/sites ;
access_log off; log_not_found off; expires max;
}
# Uncomment one of the lines below for the appropriate caching plugin (if used).
#include global/wordpress-ms-subdir-wp-super-cache.conf;
#include global/wordpress-ms-subdir-w3-total-cache.conf;
# Rewrite multisite '.../wp-.*' and '.../*.php'.
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
}
# Pass all .php files onto a php-fpm/php-fcgi server.
location ~ \.php$ {
# Zero-day exploit defense.
# http://forum.nginx.org/read.php?2,88845,page=3
# Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
# Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine. And then cross your fingers that you won't get hacked.
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_cache_bypass $no_cache
fastcgi_cache_bypass $no_cache;
fastcgi_no_cache $no_cache;
fastcgi_cache WORDPRESS;
fastcgi_cache_valid 6000m;
}
location ~ /purge(/.*) {
fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";
}
它能回答你的问题吗?