当前位置:首页 > Apache

APACHE如何里一个站点绑定多个域名?用ServerAlias servername

canca3年前 (2023-07-11)Apache466

APACHE2如何里一个站点绑定多个域名?用ServerAlias

以前很笨,要使多个域名指向同一站点总是这样写:

<VirtualHost *:80>
ServerAdmin i@kuigg.com
DocumentRoot /www/kuigg.com
ServerName kuigg.com
</VirtualHost>
<VirtualHost *:80>
ServerAdmin i@kuigg.com
DocumentRoot /www/kuigg.com
ServerName www.kuigg.com
</VirtualHost>
<VirtualHost *:80>
ServerAdmin i@kuigg.com
DocumentRoot /www/kuigg.com
ServerName abc.kuigg.com
</VirtualHost>

这样一来就等于绑了多少域名就开了多少虚拟主机…………


后来看了看书,发现有个叫”ServerAlias“的东西可以用

其实可以这样:

<VirtualHost *:80>
ServerAdmin i@kuigg.com
DocumentRoot /www/kuigg.com
ServerName kuigg.com
ServerAlias  www.kuigg.com  abc.kuigg.com
</VirtualHost>

要绑多少个域名都可以写在 ServerAlias   后面,用空格隔开即可

apache AH01630: client denied by server configuration错误解决方法

出现这个错误的原因是,apache2.4 与 apache2.2 的虚拟主机配置写法不同导致。

apache2.2的写法:

<VirtualHost *:80>  
ServerName fdipzone.demo.com  
DocumentRoot "/home/fdipzone/sites/www"  
DirectoryIndex index.html index.php  
  <Directory "/home/fdipzone/sites/www">  
    Options -Indexes +FollowSymlinks  
    AllowOverride All  
    Order deny,allow  
    Allow from all  
  </Directory>  
</VirtualHost>

如果在2.4中使用以上写法就会有apache AH01630: client denied by server configuration错误。

解决方法,apache2.4中

Order deny,allow  
Allow from all  
Allow from host ip  
 
Require all granted  
Require host ip

修改后的配置如下:

<VirtualHost *:80>  
 ServerName fdipzone.demo.com  
 DocumentRoot "/home/fdipzone/sites/www"  
 DirectoryIndex index.html index.php  
  
 <Directory "/home/fdipzone/sites/www">  
  Options -Indexes +FollowSymlinks  
  AllowOverride All  
  Require all granted  
 </Directory>  
</VirtualHost>

扫描二维码推送至手机访问。

版权声明:本文由Ant.Master's Blog发布,如需转载请注明出处。

本文链接:https://iant.work/post/850.html

分享给朋友:

“APACHE如何里一个站点绑定多个域名?用ServerAlias servername” 的相关文章

apache对页面进行压缩和页面缓存来提升性能

            网站的访问速度是由多个因素所共同决定的,这些因素例如应用程序的响应速度、网络带宽、服务器性能、与客户端之间的网络传输速度等等。其中最重要的一个因素是应用程序...…

授权Apache2 + PHP读写目录权限

摘要:您需要将目录的所有者设置为PHP使用的用户(Web服务器用户)。步骤1:确定PHP用户…

Apache下htaccess文件不起作用/rewrite 没有效果

【Apache下rewrite不成功】不成功按照如下三步排查:【第一步:打开rewrite 模块没有】首先 我们找到apache安装目录下的 /conf/http.cnf打开,文件 搜索rewrite 找到#LoadModule rewrite_module modules/mod_rewrite.…

Tomcat启动报错或警告: org.apache.catalina.webresources.Cache.getResource Unable to add the resource

关于缓存空间不足倒置无法添加资源的解决办法!相信很多朋友都遇到过了吧。报错信息如下:**为任意位置org.apache.catalina.webresources.Cache.getResource Unable to add the resourc…

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。