我在 Apache 服務器上安裝了作業的 WordPress,并希望遷移到 VPS 上的 NGINX 服務器。我已經復制了所有檔案,設定了 MSQL 連接等,一切似乎都運行良好,除了已發布的文章,它們都給出 404 錯誤。管理區域作業正常,沒有明顯問題。
虛擬服務器配置為:
server {
if ($host = www.xxx.es) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name xxx.es www.xxx.es;
return 301 https://www.xxx.es$request_uri;}
server {
server_name xxx.es www.xxx.es;
root /home/www/xxx.es/html/;
index index.php;
#listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/www.xxx.es/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/www.xxx.es/privkey.pem; # managed byCertbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(. ?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {return 404;}
fastcgi_param HTTP_PROXY "";
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
我已經嘗試過其他問題的解決方案但沒有成功。謝謝您的幫助
uj5u.com熱心網友回復:
嘗試改變你的部分:
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(. ?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {return 404;}
fastcgi_param HTTP_PROXY "";
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
對此:
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\. {
deny all;
}
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/471251.html
