关于用两个网址访问一个服务器上不同站点

要求就是通过http://www.xiaolu.com访问在位置f:myblog下的文件index.html;通过http://www.xiaolu1.com访问在位置f:myblog1下的index.htm文件

解决方法一、

1、配置httpd.conf文件,启用httpd-vhosts.conf

即,将#Include conf/extra/httpd-vhosts.conf前面的#去掉

2、配置httpd-vhosts.conf(位置conf/extra/httpd-vhosts.conf)

<VirturalHost 127.0.0.1:80>

DocumentRoot "f:/myblog"

DirectoryIndex index.html inde.htm index.php

<Directory />

Options FollowSymLinks

AllowOverride None

Order allow,deny

Allow from all

</Directory>

</VirtualHost>

 

<VirturalHost 127.0.0.1:81>

DocumentRoot "f:/myblog1"

DirectoryIndex index.html inde.htm index.php

<Directory />

Options FollowSymLinks

AllowOverride None

Order allow,deny

Allow from all

</Directory>

</VirtualHost>

3、在httpd.conf文件中让Apache监听81端口

Listen 81

4、在hosts文件中添加新的IP和对应域名设置

127.0.0.1  www.xiaolu.com

127.0.0.1  www.xiaolu1.com

5、访问时候

http://www.xiaolu1.com:81

解决方法二、

1、配置httpd.conf文件,启用httpd-vhosts.conf

即,将#Include conf/extra/httpd-vhosts.conf前面的#去掉

2、配置httpd-vhosts.conf

<VirturalHost *:80>

DocumentRoot "f:/myblog"

#这里指定域名

ServerName www.xiaolu.com

DirectoryIndex index.html inde.htm index.php

<Directory />

Options FollowSymLinks

AllowOverride None

Order allow,deny

Allow from all

</Directory>

</VirtualHost>

 

<VirturalHost *:80>

DocumentRoot "f:/myblog1"

ServerName www.xiaolu.com

DirectoryIndex index.html inde.htm index.php

<Directory />

Options FollowSymLinks

AllowOverride None

Order allow,deny

Allow from all

</Directory>

</VirtualHost>

3、在httpd.conf文件中设置访问权限

<Directory />
#AllowOverride none
#Require all denied
Options FollowSymLinks
AllowOverride None
Order deny,allow
# Deny from all
Allow from all
</Directory>

4、在hosts文件中添加新的IP和对应域名设置

127.0.0.1  www.xiaolu.com

127.0.0.1  www.xiaolu1.com

5、访问时候

http://www.xiaolu1.com(可以正常访问不用带:81)

 

转载于:https://www.cnblogs.com/deerfig/p/6945482.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值