windows下apache2.2配置虚拟目录(多个网站)

windows下配置apache方法

1.基于不同IP地址的虚拟主机

 

网站很多配置虚拟目录的多种方法,来实现本地配置多个网站

在apache配置文件。打开httpd.conf

 

 

DocumentRoot "D:\php5"  //可以不用注释

这下面可以加多个<VirtualHost></VirtualHost><Directory></Directory>

<VirtualHost></VitualHost>可以加自己的url重写规则

 


<VirtualHost 127.0.0.2:80>
DocumentRoot "D:\0551fangchan.com\news.0551fangchan.com"
ServerName 127.0.0.2:80
RewriteEngine on
RewriteRule /(.*)fc0(.*)_(.*)_(.*)_(.*).html /$1$2.php?id=$3&page=$4&pz=$5 [PT]
RewriteRule /(.*)fc0(.*)_(.*)_(.*).html   /$1$2.php?id=$3&page=$4 [PT]
RewriteRule /(.*)fc0(.*)_(.*).html   /$1$2.php?id=$3 [PT]
RewriteRule /(.*)fc0(.*).html /$1$2.php  [PT]
RewriteRule /(.*)_(.*).html /$1.php?zone=$2 [PT]
RewriteRule /(.*)-(.*).html /$1.php?word=$2 [PT]
</Virtualhost>

 

<Directory "D:\0551fangchan.com\news.0551fangchan.com">
    Options Indexes FollowSymLinks Multiviews
    AllowOverride All
    Order Allow,Deny
    Allow from all
</Directory>

 

<VirtualHost 127.0.0.3:80>
DocumentRoot "D:\0551fangchan.com\oldhouse.0551fangchan.com"
ServerName 127.0.0.3:80
RewriteEngine on
RewriteRule /(.*)fc0(.*)_(.*)_(.*)_(.*).html /$1$2.php?id=$3&page=$4&pz=$5 [PT]
RewriteRule /(.*)fc0(.*)_(.*)_(.*).html   /$1$2.php?id=$3&page=$4 [PT]
RewriteRule /(.*)fc0(.*)_(.*).html   /$1$2.php?id=$3 [PT]
RewriteRule /(.*)fc0(.*).html /$1$2.php  [PT]
RewriteRule /(.*)_(.*).html /$1.php?zone=$2 [PT]
RewriteRule /(.*)-(.*).html /$1.php?word=$2 [PT]
</Virtualhost>

 

<Directory "D:\0551fangchan.com\oldhouse.0551fangchan.com">
    Options Indexes FollowSymLinks Multiviews
    AllowOverride All
    Order Allow,Deny
    Allow from all
</Directory>

 

最后,还要改下C:\windows\system32\drivers\etc下hosts文件

 

127.0.0.2 news.0551fangchan.com
127.0.0.3 oldhouse.0551fangchan.com

 

然后,重启apache

   net stop apache2.2

   net start apache2.2

然后再浏览器地址栏中:http://news.0551fangchan.com

成功了吧!

 

2.基于主机的虚拟主机

 

NameVirtualHost *:80
<VirtualHost *:80>
ServerName *
DocumentRoot "D:\0551fangchan.com\www.0551fangchan.com"
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:\0551fangchan.com\news.0551fangchan.com"
ServerName news.0551fangchan.com
<Directory "D:\0551fangchan.com\news.0551fangchan.com">
    Options Indexes FollowSymLinks Multiviews
    AllowOverride All
    Order Allow,Deny
    Allow from all
</Directory>
</Virtualhost>

<VirtualHost *:80>
DocumentRoot "D:\php5"
ServerName test
DirectoryIndex phpinfo.php index.php index.html index.htm
<Directory "D:\php5">
    Options Indexes FollowSymLinks Multiviews
    AllowOverride All
    Order Allow,Deny
    Allow from all
</Directory>
</Virtualhost>

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值