1
我已經安裝了一個WP博客,並在nginx服務器塊配置上爲它添加了一個位置塊。當訪問博客example.com/blog
或任何博客文章如example.com/blog/foo-bar-baz
時,將提供內容但缺少所有資產。PHP資產沒有被nginx服務
當我檢查日誌時,它看起來像對這些資產URL的所有請求都將永久重定向到根博客URL。下面是nginx的的訪問日誌的請求的例子:
"GET /blog/wp-includes/js/jquery.min.js HTTP/1.1" 301 5 "https://example.com/blog/" "USER_AGENT_STRING"
下面是nginx的配置:
server {
listen 80;
server_name www.example.com example.com;
return 301 https://www.example.com$request_uri;
}
server {
listen 443 ssl;
server_name example.com www.example.com;
root /home/example/current/public;
index index.html index.htm;
location ~ /blog {
index index.php index.html index.htm;
fastcgi_param SCRIPT_FILENAME /var/www/blog/index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_buffers 256 128k;
fastcgi_connect_timeout 300s;
fastcgi_send_timeout 300s;
fastcgi_read_timeout 300s;
include fastcgi_params;
}
}
如何編輯任一位置塊有nginx的捉對所有的URL請求是包含/blog/wp-content/
或/blog/wp-includes/
?我嘗試添加以下位置塊,但它不起作用:
location ~ ^(/wp-content/|/wp-includes/)/.*\.(jpe?g|gif|css|png|js|ico|pdf|m4a|mov|mp3)$ {
root /var/www/blog;
}