我的服務器應用程式使用 Laravel,直到最近我還在托管一個 wordpress 博客blog.server.com
我希望將其更改為server.com/blog
我通過添加以下內容更新了主要的 nginx 配置:
location ^~ /blog {
root /home/ploi/blog.server.com/public;
index index.php index.html index.htm;
try_files $uri $uri/ /blog/index.php?$query_string;
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(. \.php)(/. )$;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_buffers 16 16k;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
這種作品。它會加載新的 /blog url 和帖子,但是:
- 沒有加載靜態資產 (
js, png, css, etc) server.com/blog/wp-admin/無限回圈
我該如何解決這個問題?
uj5u.com熱心網友回復:
你可以試試這個,為我作業:
location /blog {
alias /home/ploi/blog.server.com/public;
try_files $uri $uri/ @blogrewrite;
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
}
location @blogrewrite {
rewrite /blog/(.*)$ /blog/index.php?/$1 last;
}
我使用了“命名位置”(@blogrewrite),但坦率地說,我不知道為什么這是必要的,但它避免了遞回。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/471256.html
