【发布时间】:2017-09-15 05:28:25
【问题描述】:
我已向 ubuntu droplets 添加了 2 个域。 a.com 和 b.com。两个 A 记录都重定向到 IP。
我还为这两个域创建了虚拟主机。喜欢
server {
listen 80;
listen [::]:80;
root /var/www/html/b.com;
# Add index.php to the list if you are using PHP
index index.html index.htm index.php index.nginx-debian.html;
server_name b.com www.b.com;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
但是 b.com 没有重定向到期望文件夹。当我从 url 访问域时。它重定向到主 IP 文件夹,如 /var/www/html 而不是 /var/www/html/b.com
我的默认虚拟主机
server {
listen 80;
listen [::]:80;
root /var/www/html/;
# Add index.php to the list if you are using PHP
index index.html index.htm index.php index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
我按照这些说明操作但仍然无法正常工作:https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04
【问题讨论】:
标签: php redirect nginx ubuntu-16.04