配置apache的多域名解析,需要用到下面的东西:
上面的文件的用处后面会提到,先讲讲基本情况,客户有两个域名:
这两个域名要绑定某服务器上两个网站,假设目录为:
首先在apache的httpd.conf中将虚拟主机模块打开,就是将前面的#号去掉:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
然后引入虚拟主机配置模块:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
然后在httpd-vhosts.conf中写入以下内容:
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerAdmin fillbag@hotmail.com
DocumentRoot "D:/htdocs/yeboots.com"
ServerName *.yeboots.com
ErrorLog "logs/yeboots.com-error.log"
CustomLog "logs/yeboots.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin fillbag@hotmail.com
DocumentRoot "D:/htdocs/yecsc.com"
ServerName yecsc.com
ServerAlias *.yecsc.com
ErrorLog "logs/yecsc.com-error.log"
CustomLog "logs/yecsc.com-access.log" common
</VirtualHost>
便实现了多域名指向服务器不同目录。其中红色部分是实现泛域名解析的方法。
注意点:
推荐网址:
其中有一个问题好长时间没有调试出来,最后找到的原因,就是下图中的第二行:
<!–StartFragment –>
注释掉之后,两个网站终于可以各自访问各自的目录了。
所以要非常注意本机HOST文件中对localhost的配置,否则会出莫名奇妙的状况。
原文链接:https://blog.csdn.net/qdujunjie/article/details/83572346?ops_request_misc=&request_id=a44a482304354872b5e6b2163b77ebd4&biz_id=&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~koosearch~default-15-83572346-null-null.268%5Ev1%5Econtrol&utm_term=%E9%BB%91%E7%BE%A4%E6%99%96%E3%80%81docker%E3%80%81%E5%AE%B9%E5%99%A8%E9%95%9C%E5%83%8F%E3%80%81%E5%9F%9F%E5%90%8D%E6%B3%A8%E5%86%8C%E3%80%81%E5%AE%9D%E5%A1%94%E3%80%81%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86%E3%80%81nginx%E3%80%81frp%E3%80%81%E5%8A%A8%E6%80%81%E5%9F%9F%E5%90%8D%E8%A7%A3%E6%9E%90%E3%80%81NAS%E3%80%81%E7%BE%A4%E6%99%96%E3%80%81%E9%98%BF%E9%87%8C%E4%BA%91%E3%80%81%E5%9F%9F%E5%90%8D%E8%A7%A3%E6%9E%90%E3%80%81%E5%86%85%E7%BD%91%E7%A9%BF%E9%80%8F%E3%80%81ipv6%E3%80%81ddns%E3%80%81%E8%BD%BB%E9%87%8F%E7%BA%A7%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8%E3%80%81%E9%93%81%E5%A8%81%E9%A9%AC%E3%80%81%E5%A8%81%E8%81%94%E9%80%9A%E3%80%81DSM%E3%80%81DSM6.0%E3%80%81%E7%BE%A4%E6%99%96nas%E3%80%81%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8%E3%80%81%E8%9C%97%E7%89%9B%E6%98%9F%E9%99%85