apache虚拟目录配置

开启模块支持

LoadModule vhost_alias_module modules/mod_vhost_alias.so

基于域名的虚拟目录设计

注:低版本可能需要 配置项中 NameVirtualHost *:80 的支持

#匹配localhost访问的地址
<VirtualHost *:80>
	ServerName localhost
	DocumentRoot "D:\www"
	<Directory "D:\www"> 
		Options FollowSymLinks IncludesNOEXEC Indexes
		DirectoryIndex index.html index.php default.php
		AllowOverride All
		Order Deny,Allow 
		Allow from all 
	</Directory>
</VirtualHost>

#匹配test1.domain.site访问的地址
<VirtualHost *:80>
	ServerName test1.domain.site
	DocumentRoot "D:\www\test1"
	<Directory "D:\www\test1"> 
		Options FollowSymLinks IncludesNOEXEC Indexes
		DirectoryIndex index.html index.php default.php
		AllowOverride All
		Order Deny,Allow 
		Allow from all 
	</Directory>
</VirtualHost>

#匹配test2.domain.site访问的地址
<VirtualHost *:80>
	ServerName test1.domain.site
	DocumentRoot "D:\www\test2"
	<Directory "D:\www\test2"> 
		Options FollowSymLinks IncludesNOEXEC Indexes
		DirectoryIndex index.html index.php default.php
		AllowOverride All
		Order Deny,Allow 
		Allow from all 
	</Directory>
</VirtualHost>


修改C:\Windows\System32\drivers\etc\hosts
127.0.0.1 localhost
127.0.0.1 test1.domain.site
127.0.0.1 test2.domain.site


基于端口的虚拟目录配置

Listen 8080
<VirtualHost *:8080>
	ServerName localhost
	DocumentRoot "D:\www"
	<Directory "D:\www">
		Options FollowSymLinks IncludesNOEXEC Indexes
		DirectoryIndex index.html index.php default.php
		AllowOverride All
		Order Deny,Allow
		Allow from all
	</Directory>
</VirtualHost>

Listen 8081
<VirtualHost *:8081>
	ServerName localhost
	DocumentRoot "D:\www\test1"
	<Directory "D:\www\test1">
		Options FollowSymLinks IncludesNOEXEC Indexes
		DirectoryIndex index.html index.php default.php
		AllowOverride All
		Order Deny,Allow
		Allow from all
	</Directory>
</VirtualHost>

Listen 8082
<VirtualHost *:8082>
	ServerName localhost
	DocumentRoot "D:\www\test2"
	<Directory "D:\www\test2">
		Options FollowSymLinks IncludesNOEXEC Indexes
		DirectoryIndex index.html index.php default.php
		AllowOverride All
		Order Deny,Allow
		Allow from all
	</Directory>
</VirtualHost>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值