httpd.conf 文件:
<Directory "d:/wamp/www/">目录权限
DocumentRoot "d:/wamp/www/"根目录
要修改根目录直接改这两个就可以了。
一、关于虚拟目录:
什么是虚拟目录?顾名思义虚拟目录就是虚拟的目录。下面例子:原来访问"D:/wamp/www/taobao/"的地址栏应输入:localhost/taobao。如下配置虚拟目录之后,就可以在地址栏输入 localhost/tb了。这样做的原因有很多,其中之一就是安全问题,因为那样别人就会知道你的根目录文件夹。
Alias /tb/ "D:/wamp/www/taobao/"
<Directory "D:/wamp/www/taobao">
AllowOverride all
Options FollowSymLinks
Order allow,deny
Allow from all
</Directory>
二、配置虚拟主机:
关于虚拟主机,在我们安装Apache的时候一般默认的Apache的配置是只有一个网站的,这样切换起来很不方便。把本机Apache配置成虚拟服务器,就可以很好的解决这个问题。
1、配置虚拟目录需去掉 httpd.conf 中 Include conf/extra/httpd-vhosts.conf 前的“#”;
2、在httpd-vhosts.conf中添加
<VirtualHost *:80>
ServerName test.thinkphp.com //此为虚拟主机
ServerAlias zhanhui.thinkphp.com //此为别名
DocumentRoot "D:\www\wamp\thinkphp"
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
</IfModule>
<Directory "D:\www\wamp\thinkphp">//此为虚拟目录
AllowOverride all
Options FollowSymLinks
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName test.taobao.com //此为虚拟主机
ServerAlias zhanhui.taobao.com //此为别名
DocumentRoot "D:\www\wamp\taobao"
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
</IfModule>
<Directory "D:\www\wamp\taobao">//此为虚拟目录
AllowOverride all
Options FollowSymLinks
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
然后在hosts文件中添加:
127.0.0.1test.thinkphp.com
127.0.0.1test.taobao.com