小编Var*_*kal的帖子

子目录中的 Nginx 和 PHP

我在 nginx 后面有一个应用程序。但我需要此应用程序中的特定路径重定向到 Wordpress 博客

例子 :

example.com/ -------> 重定向到我的应用程序

example.com/whatever/ -------> 也重定向到我的应用程序

example.com/blog/ ------->重定向到我的 Wordpress 博客

所以,我添加了一个匹配这个子路径的位置

server {
        listen 80 default_server;

        index index.php;

        server_name _;

        location ^~ /blog {
                root /path/to/my/blog;
                index index.php index.html;

                location ^~ /blog/(.*\.php)$ {
                   fastcgi_pass   127.0.0.1:9000;
                   fastcgi_index index.php;
                   fastcgi_param  SCRIPT_FILENAME  /path/to/my/blog/$fastcgi_script_name;
                   include fastcgi_params;
                }
        }

        location ~* /(.*) {
                #here the conf for the rest of the website
        }
}
Run Code Online (Sandbox Code Playgroud)

当我尝试获取该页面时,我在日志中有一个带有此错误的 404:

2016/05/22 15:27:24 [error] 21759#0: *1 open() "/path/to/my/blog/blog/index.php" failed (2: No such file …
Run Code Online (Sandbox Code Playgroud)

php nginx php-fpm

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

nginx ×1

php ×1

php-fpm ×1