售前咨询
技术支持
渠道合作

Nginx泛解析的匹配域名绑定到子目录配置

 

Nginx泛解析的匹配域名绑定到子目录配置,有2种方法,推荐方法一

方法一:

  1. server {
  2. listen 80;
  3. server_name ~^(?<subdomain>.+).trustauth.cn$;
  4. access_log /data/wwwlogs/trustauth.cn_nginx.log combined;
  5. index index.html index.htm index.php;
  6. root /home/wwwroot/linuxeye/$subdomain/;
  7. location ~ .php$ {
  8.     fastcgi_pass unix:/dev/shm/php-cgi.sock;
  9.     fastcgi_index index.php;
  10.     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  11.     include fastcgi_params;
  12.     }
  13. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
  14.     expires 30d;
  15.     }
  16. location ~ .*\.(js|css)?$ {
  17.     expires 7d;
  18.     }
  19. }

方法二:

  1. server {
  2. listen 80;
  3. server_name *.trustauth.cn;
  4. access_log /home/wwwlogs/trustauth.cn_nginx.log combined;
  5. index index.html index.htm index.php;
  6. if ($host ~* ^([^\.]+)\.([^\.]+\.[^\.]+)$) {
  7.     set $subdomain $1;
  8.     set $domain $2;
  9. }
  10. location / {
  11.     root /home/wwwroot/trustauth.cn/$subdomain/;
  12.     index index.php index.html index.htm;
  13. }
  14. location ~ .php$ {
  15.     fastcgi_pass unix:/dev/shm/php-cgi.sock;
  16.     fastcgi_index index.php;
  17.     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  18.     include fastcgi_params;
  19.     }
  20. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
  21.     expires 30d;
  22.     }
  23. location ~ .*\.(js|css)?$ {
  24.     expires 7d;
  25.     }
  26. }

上一篇:

下一篇:

相关新闻

 

领取优惠
免费预约

申请试用SSL证书

提交成功!

咨询客服