请问这种情况下如何配置APACHE?

查看:97
本文介绍了请问这种情况下如何配置APACHE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

192.168.1.13上安装了apache服务,apache的根目录下有站点1,根目录下的site2目录下有站点2
现有两个域名通过代理指向192.168.1.13,一个域名作为站点2的域名,一个域名作为站点2的附件访问域名。
在不修改配置文件时可以通过http://www.xpdent.cn/site2/in...方式访问站点2

<VirtualHost *:80>
    ServerName www.xpdent.cn
    ServerAlias www.xpdent.cn
    Alias / /data/www/html/site2/
    DocumentRoot /data/www/html/site2
    DirectoryIndex  index.html
</VirtualHost>
<VirtualHost *:80>
    ServerName file.xpdent.cn
    ServerAlias file.xpdent.cn
    Alias / /data/www/html/site2/
    DocumentRoot /data/www/html/site2
    DirectoryIndex  index.html
</VirtualHost>

发现在sites-availiable000-default.conf中增加以上配置后,www.xpdent.cn这个域名只能访问站点2首页,其他目录和文件都不能访问,报404错误。 http://www.xpdent.cn/ 可以访问首页 http://www.xpdent.cn/index.php 报404错误不能访问 http://www.xpdent.cn/index.html 报404错误不能访问

请问应该如何配置?

解决方案

ServerAlias 是另外的域名,如果没有就不用写。
Alias可以去掉,DocumentRoot直接写实际路径。

<VirtualHost *:80>
    ServerName www.xpdent.cn
    ServerAlias xpdent.cn
    DocumentRoot /data/www/html
    DirectoryIndex  index.html
</VirtualHost>
<VirtualHost *:80>
    ServerName file.xpdent.cn
    DocumentRoot /data/www/html/site2
    DirectoryIndex  index.html
</VirtualHost>

这篇关于请问这种情况下如何配置APACHE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆