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/;
}