Ubuntu 如何在nginx中配置多个子域?
我想向我的网站添加子域,该网站位于Ubuntu 如何在nginx中配置多个子域?,ubuntu,nginx,configuration,server,Ubuntu,Nginx,Configuration,Server,我想向我的网站添加子域,该网站位于nginx上。为此,我将子域名添加到nginx.conf文件中。但每当我试图访问localhost之外的子域时,它就会将我重定向到http://id.domain-error.com/noresult.php 这是我的nginx.conf文件: http { server { listen 80; # Incoming port for Nginx server_name www.example.com example.com;
nginx
上。为此,我将子域名添加到nginx.conf
文件中。但每当我试图访问localhost之外的子域时,它就会将我重定向到http://id.domain-error.com/noresult.php
这是我的nginx.conf
文件:
http {
server {
listen 80; # Incoming port for Nginx
server_name www.example.com example.com;
index index.html index.htm;
location / {
root /usr/share/nginx/example;
try_files $uri $uri/ =404;
}
}
server {
listen 80; # Incoming port for Nginx
server_name hello.example.com;
index index.html index.htm;
location / {
root /usr/share/nginx/some_other_example;
try_files $uri $uri/ =404;
}
}
}
有人能告诉我这里缺少什么吗?正如@Alexey所指出的,我需要在DNS配置中添加子域。我只是添加了一个通配符符号
*.example.com
,它就开始工作了 正如@Alexey所指出的,我需要在DNS配置中添加子域。我只是添加了一个通配符符号*.example.com
,它就开始工作了 您是否已将它们添加到DNS?这就是错误所在。完全忘记添加它了。刚刚添加了*.example.com
,效果不错。谢谢。你把它们添加到DNS了吗?那是错误。完全忘记添加它了。刚刚添加了*.example.com
,效果不错。谢谢