apache虚拟主机之间重写_关于apache一些你必须清楚知道的小事情

9a9fdc65e1d807956117387850a23210.png

Hello,apache!

关于apache的一些你必须知道的事情

配虚拟主机

4e5aa16c06ad992558610496068d867f.png
图1-0:事先搞好几个文件目录

72387728d148f8c2fbf2e655faab6661.png
图1-1:host文件中先定两个你中意的域名
host文件目录:"C:WindowsSystem32driversetc"
127.0.0.1 www.first.com
127.0.0.1 www.second.com

516fcdb6cb69c8e8530793f11a06b1af.png
图1-2:确保您的httpd.conf文件开启httpd-vhosts.conf扩展配置

4f9f4be56f4748f52bd8a4cddc1d6ce6.png
图1-3:确保配置的文件目录FirstSite/&SecondSite/存在
<VirtualHost *:80>
	ServerName www.first.com
	ServerAlias www.first.com
	DocumentRoot F:/code/FirstSite/
	DirectoryIndex index.html index.php index.htm
	<Directory  "F:/code/FirstSite/">
		Options +Indexes +Includes +FollowSymLinks +MultiViews
		AllowOverride All
		Require local
	</Directory>
</VirtualHost>

<VirtualHost *:80>
	ServerName www.second.com
	ServerAlias www.second.com
	DocumentRoot F:/code/SecondSite/
	DirectoryIndex index.html index.php index.htm
	<Directory "F:/code/SecondSite/>
		Options +Indexes +Includes +FollowSymLinks +MultiViews
		AllowOverride All
		Require local
	</Directory>
</VirtualHost>

开启外部配置文件.htaccess

.htaccess该文件配置的修改无须重启apache服务
用处:url的重写规则,使用户输入的url美观简洁,需要结合正则来处理了
<VirtualHost *:80>
	ServerName www.myphp.com
	ServerAlias www.myphp.com
	DocumentRoot F:/code/Myphp/
	DirectoryIndex index.html index.php index.htm
	<Directory  "F:/code/Myphp/">
		Options +Indexes +Includes +FollowSymLinks +MultiViews
		AllowOverride All		
		# 开启外部配置文件.htaccess
		AllowOverride all #all 开启,none 关闭	
		Require local
	</Directory>
</VirtualHost>

7c1054b56689bf7c616f5b2416219f6c.png
图2-0:开启外部配置文件.htaccess
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值