Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.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子目录根问题_Wordpress_Nginx - Fatal编程技术网

Wordpress Nginx子目录根问题

Wordpress Nginx子目录根问题,wordpress,nginx,Wordpress,Nginx,我在/usr/local/nginx/html上有一个webroot。(本地主机) 我在/usr/local/nginx/html/hi.com/public上安装了WordPress 我想从http://localhost/hi.com 这是我搞砸的配置: location /hi.com { root /usr/local/nginx/html/hi.com/public; } 当我转到http://localhost/hi.com/humans.txt它试图从/usr

我在
/usr/local/nginx/html
上有一个webroot。(本地主机)

我在
/usr/local/nginx/html/hi.com/public
上安装了WordPress

我想从
http://localhost/hi.com

这是我搞砸的配置:

  location /hi.com {
      root /usr/local/nginx/html/hi.com/public;
  }
当我转到
http://localhost/hi.com/humans.txt
它试图从
/usr/local/nginx/html/hi.com/public/hi.com/humans.txt
而不是从所需的
/usr/local/nginx/html/hi.com/public/humans.txt
位置抓取
humans.txt

你知道我该怎么解决这个问题吗


已经杀了我。

这里的问题是您使用的是
root
而不是
alias

  • root
    将以这种方式工作():

    • 获取:
      http://localhost/hi.com/humans.txt
    • 响应:
      /usr/local/nginx/html/hi.com/public/hi.com/humans.txt
  • alias
    将以这种方式工作():

    • 获取:
      http://localhost/hi.com/humans.txt
    • 响应:
      /usr/local/nginx/html/hi.com/public/humans.txt

为此,正确的选择是使用
别名

您能否发布整个Nginx配置,它可能会有所帮助。它位于“站点可用/默认”下
location /hi.com/ {
    root /usr/local/nginx/html/hi.com/public/;
}
location /hi.com/ {
    alias /usr/local/nginx/html/hi.com/public/;
}