nginx 怎么根据不同子域名对应不同目录的资源文件 ?
黄舟
黄舟 2017-05-16 17:12:52
[Linux讨论组]

例如:a.example.com/index.html 对应 /a-direcoty/index.html,而b.example.com/index.html 对应 /b-direcoty/index.html

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

全部回复(2)
给我你的怀抱
server {
listen 80;
server_name ~^(?<subdomain>.+).example.com$;
index index.html index.htm;
root /$subdomain-direcoty/;
}
phpcn_u1582

nginx配置文件可以设置server段,在server中设置server_name来指定域名。所以你这种情况就设置两个server,分别是两个域名,然后再设置root为具体目录

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号