apache下配置多个网站
apache下配置多个网站:
httpd.conf配置文件里 找到
Include conf/extra/httpd-vhosts.conf
去掉前面的注释;//引入httpd-vhosts.conf文件
在conf\extra\httpd-vhosts.conf文件里配置:
NameVirtualHost 127.0.0.1:80 //虚拟主机名
<VirtualHost 127.0.0.1:80> //虚拟主机
ServerName 127.0.0.1
<Location />
Order Deny,Allow
Deny from all
</Location>
</VirtualHost>
// 一台虚拟主机的共同部分
//配置多个网站,复制一下部分;修改成不同网站内容。
<VirtualHost 127.0.0.1:80>
DocumentRoot "htdocs/" //文件路径
ServerName www.a.com //域名
ErrorDocument 404 /404.html //404页面设置
<Directory / >
Options FollowSymLinks
AllowOverride all
Order Allow,Deny
Allow from all
Deny from 127.0.0.100
</Directory> //网站权限设置
DirectoryIndex index.html index.htm index.php //默认页面文档
</VirtualHost>
<VirtualHost 127.0.0.1:80>
ServerName a.com
RewriteEngine on
RewriteRule ^/(.*)$ http://www.a.com/$1
</Virtualhost>