论坛首页 编程语言技术论坛

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

浏览 8959 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2010-07-31   最后修改:2010-11-19
PHP

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>

 

 

论坛首页 编程语言技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics