隐藏

配置本地开发机器虚拟域名以及泛域名解析

发布:2019/5/1 8:49:37作者:管理员 来源:本站 浏览次数:1122

配置本地开发机器虚拟域名以及泛域名解析

适合在本地进行多站点开发配置

1、配置:C:\Windows\System32\drivers\etc\hosts 添加

127.0.0.1 a.la

127.0.0.1 qwadmin.a.la

127.0.0.1 test.a.la

2、nignx配置

server {

listen 80;

#server_name test.a.la;

server_name ~^(?<subdomain>.+).a.la$;

index index.html index.htm index.php;

root D:/web/$subdomain;

location ~ \.php$ { root D:/web/$subdomain; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param domain $subdomain; include fastcgi_params;

 }
 } 

作用说明: 在目录 D:/web/ 里添加 test虚拟目录站点,在hosts文件里 添加 test的二级域名映射如:127.0.0.1 test.a.la,刚可以通过 test.a.la 直接访问test站,不需求重启nginx