我不习惯来自Apache2的Nginx yet...migrating。我不理解位置和根目录指令……我读到根目录最适合用在alias...so上,我让所有根目录都是绝对路径。
此处的服务器块:
index index.php index.html;
location = / {
root /var/www/app;
}
location /chat/ {
root /var/www/project1/chat;
}
location /kanban/ {
root /var/www/kanban;
}
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
include fastcgi_params;
}当我有根目录/var/www/app;在位置块之外时,主index.php就可以工作了。然而,当添加带有根路径的位置块时,我得到的所有页面都是404页。我希望不需要为每个已定义的位置添加PHP位置块,这肯定不是必需的,对吧?
对于我的每个项目,我只想让www.site.com转到/var/www/app/index.php和www.site.com/chat/转到/var/www/project1/chat/index.php等等。
发布于 2018-06-24 12:16:32
要将mywebsite.com/chat重定向到不同于网站根目录的目录,您可以使用类似以下代码的代码。
root var/www/app;
index index.html index.php;
location /chat/ {
alias /var/www/project1/chat/;
index index.php;
}https://stackoverflow.com/questions/51006853
复制相似问题