我想为托管在 nginx
上的网站添加子域。为此,我将子域名添加到 nginx.conf
文件中。但是每当我尝试访问本地主机之外的子域时,它都会将我重定向到 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
并且它开始工作了。
关于ubuntu - 如何在nginx中配置多个子域?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35909499/