当前位置:首页 > Apache

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

canca3年前 (2023-07-11)Apache514

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” 的相关文章

AppServ 2.5.9 中集成的 各个软件的版本

AppServ是PHP网页架站工具组合包,泰国的作者将一些网路上免费的架站资源重新包装成单一的安装程序,以方便初学者快速完成架站,AppServ 所包含的软件有:Apache、Apache Monitor、PHP、MySQL、PHP-Nuke、phpMyAdmin。 AppServ 2.5.9 Ap…

Apache URLRewriter

今日折腾网站,不得不用到了Apache 的Rewrite功能,虽说我对正则表达式并不陌生,但这东西学完就忘,忘了再学一样吃力,并且正则表达式只是学习Rewrite的一个方面。半天下来心急火燎,最终事没有办成,最后还是静下心来琢磨,总算蒙…

授权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…

发表评论

访客

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