Plesk 子文件夹 /blog WordPress nginx 404 未找到



我有一个 aws lightsail 实例。在 plesk 面板中,我有一个节点.js webiste,其中有一个包含 wordpress 网站的博客文件夹。主网站和博客主页没有问题。但是,如果我单击任何博客文章,则会收到404未找到nginx错误。

我更改了nginx.conf文件,但没有任何变化。

我的nginx.conf文件在/var/www/vhosts/system/example.com/conf/下

server {
listen 171.26.10.103:443 ssl http2;
server_name example.com;
server_name www.example.com;
server_name ipv4.example.com;
ssl_certificate/opt/psa/var/certificates/certSiSwQOP;
ssl_certificate_key/opt/psa/var/certificates/certSiSwQOP;
client_max_body_size 128m;
# mailconfig
location ~* ^/autodiscover/autodiscover.xml$ {
try_files $uri @mad;
}
location ~* ^(/.well-known/autoconfig)?/mail/config-v1.1.xml$ {
try_files $uri @mad;
}
location @mad {
rewrite ^(.*)$ /mailconfig/ break;
proxy_passhttp://127.0.0.1:8880;
proxy_set_header X-Host$host;
proxy_set_header X-Request-URI$request_uri;
}
# mailconfig
root "/var/www/vhosts/example.com/httpdocs";
access_log "/var/www/vhosts/system/example.com/logs/proxy_access_ssl_log";
error_log "/var/www/vhosts/system/example.com/logs/proxy_error_log";
#extension letsencrypt begin
location ^~ /.well-known/acme-challenge/ {
root /var/www/vhosts/default/htdocs;
types { }
default_type text/plain;
satisfy any;
auth_basic off;
allow all;
location ~ ^/.well-known/acme-challenge.*/. {
deny all;
}
}
#extension letsencrypt end
#extension sslit begin
#extension sslit end
location / {
proxy_pass https://171.26.10.103:7081;
proxy_set_header Host$host;
proxy_set_header X-Real-IP$remote_addr;
proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
proxy_set_header X-Accel-Internal /internal-nginx-static-location;
access_log off;
location /internal-nginx-static-location/ {
alias /var/www/vhosts/example.com/httpdocs/;
internal;
}
location ~ ^/(plesk-stat|awstats-icon|webstat|webstat-ssl|ftpstat|anon_ftpstat) {
proxy_pass https://171.26.10.103:7081;
proxy_set_header Host$host;
proxy_set_header X-Real-IP$remote_addr;
proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
proxy_set_header X-Accel-Internal /internal-nginx-static-location;
access_log off;

location ~ "^/files/" {
proxy_pass https://171.26.10.103:7081;
proxy_set_header Host$host;
proxy_set_header X-Real-IP$remote_addr;
proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
proxy_set_header X-Accel-Internal /internal-nginx-static-location;
access_log off;
}
location /blog {
index index.php index.html index.htm;
try_files $uri $uri/ /blog/index.php?q=$uri&$args;
}
add_header X-Powered-By PleskLin;
}

server {
listen 172.26.10.103:80;
server_name example.com;
server_name www.example.com;
server_name ipv4.example.com;
client_max_body_size 128m;
# mailconfig
location ~* ^/autodiscover/autodiscover.xml$ {
try_files $uri @mad;
}
location ~* ^(/.well-known/autoconfig)?/mail/config-v1.1.xml$ {
try_files $uri @mad;
}
location @mad {
rewrite ^(.*)$ /mailconfig/ break;
proxy_passhttp://127.0.0.1:8880;
proxy_set_header X-Host$host;
proxy_set_header X-Request-URI$request_uri;
}
# mailconfig
return 301 https://$host$request_uri;
}

这解决了我的问题 https://support.plesk.com/hc/en-us/articles/213912945 在 Plesk 中,将以下内容添加到 WordPress 域的 Domains> example.com> Apache & nginx Settings 中的 Other nginx 指令字段中:

if (!-e $request_filename) {
set $test P;
}
if ($uri !~ ^/(plesk-stat|webstat|webstat-ssl|ftpstat|anon_ftpstat|awstats-icon|internal-nginx-static-location)) {
set $test "${test}C";
}
if ($test = PC) {
rewrite ^/(.*)$ /blog/index.php?$1;
}

最新更新