我在Nginx上设置了A
名称域名,我在Digital Ocean上也设置了通配符DNS。
我希望我的主域名指向它的位置:/usr/share/nginx/html/mission13.io
然后,我希望所有通配符域指向其各自的文件夹:
/usr/share/nginx/html/sub1.mission13.io
/usr/share/nginx/html/sub2.mission13.io
/usr/share/nginx/html/sub3.mission13.io
这是我所拥有的,但我不知道该怎么做让他们指向正确的位置。我可以改变什么呢?
server{
listen 80;
root /usr/share/nginx/html/mission13.io;
index index.php index.html index.htm;
server_name mission13.io www.mission13.io *.mission13.io;
location / {
try_files $uri $uri/ /index.html;
}
include /usr/share/nginx/conf/mission13.io.conf;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
答案 0 :(得分:0)
知道了!
我需要像这样使用$ http_host:
root /usr/share/nginx/html/$http_host;
答案 1 :(得分:0)
另一种方法请将服务器名称更改为_
然后它将搜索root /usr/share/nginx/html/
directory.so中主机名的文件夹,您的目录看起来很干净
server{
listen 80;
root /usr/share/nginx/html;
index index.php index.html index.htm;
server_name _;
location / {
try_files $uri $uri/ /index.html;
}
include /usr/share/nginx/conf/mission13.io.conf;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}