Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 如何使用nginx将URI(位置路径)传递给代理?_Wordpress_Nginx - Fatal编程技术网

Wordpress 如何使用nginx将URI(位置路径)传递给代理?

Wordpress 如何使用nginx将URI(位置路径)传递给代理?,wordpress,nginx,Wordpress,Nginx,我正在使用WordPress和nginx 我需要设置2个访问位置: mydomainname.com/-nginx将返回静态文件 mydomainname.com/wordpress-nginx将传递给PHP/wordpress 我有以下nginx配置文件: # https://mydomainname.com - Port 443 =========================================== server { listen 127.0.

我正在使用WordPress和nginx

我需要设置2个访问位置:

  • mydomainname.com/-nginx将返回静态文件
  • mydomainname.com/wordpress-nginx将传递给PHP/wordpress
我有以下nginx配置文件:

    # https://mydomainname.com - Port 443 ===========================================
server {
    listen       127.0.0.1 ssl;
    server_name  mydomainname.com;
    ssl_certificate /usr/local/etc/letsencrypt/live/mydomainname.com/fullchain.pem;
ssl_certificate_key /usr/local/etc/letsencrypt/live/mydomainname.com/privkey.pem;
ssl_trusted_certificate /usr/local/etc/letsencrypt/live/mydomainname.com/fullchain.pem;
    include  /usr/local/nginx/conf/ssl.conf;
    location / {
        root /usr/local/www/mydomainname.com;
    index index.html;
    }


    index index.php;
    location /wordpress  {                           # I also tried "/wordpress/"
        try_files $uri $uri/ /index.php?$args;
    }
    location ~ \.php$ {
        root           /usr/local/www/mydomainname.com/wordpress;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}
我想我知道问题所在:URI“/wordpress”或“/wordpress”被删除,而不是传递给PHP/wordpress

我正在试图找出如何将“/wordpress”或“/wordpress/”路径传递到PHP/wordpress

我试过了,但没用


有人能帮忙吗?谢谢

root
语句移动到
server
块中,并允许所有位置块继承相同的值。此外,WordPress URI的前缀应为
/WordPress/

例如:

root /usr/local/www/mydomainname.com;

location / {
    index index.html;
}

location /wordpress  {
    index index.php;
    try_files $uri $uri/ /wordpress/index.php?$args;
}

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_pass   127.0.0.1:9000;
    include        fastcgi_params;
    fastcgi_param  SCRIPT_FILENAME  $request_filename;
}

嗯,我试过了,但没用。看起来好像有一个打字错误,try_files$uri=404;“”。我试图解决它,但我认为它不是“try_files$uri$uri//wordpress/index.php?$args;”,因为它正在查找wordpress目录。它应该是“try_files$uri$uri//index.php?$args;”,但将“wordpress”作为uri传递到请求中。我该怎么做?