1.首先在你的系统盘下C:/Windows/System32/drivers/etc找到hosts文件,用记事本打开如下:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
# ::1 localhost
127.0.0.1 www.youdomain.com
其中www.youdomain.com为你的虚拟主机
2.在你的apache下的httpd.conf下添加Include conf/extra/vhosts.conf,再在extra文件夹下写一下vhost.conf文件,如下:
NameVirtualHost 127.0.0.1:80
<VirtualHost www.youdomain.com:80>
ServerName www.youdomain.com
DocumentRoot "E:/youdomain.com/document_root"
<Directory "E:/youdomain.com/document_root">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
需要开启httpd.conf的LoadModule rewrite_module modules/mod_rewrite.so
重启apache,这样就OK了。
不过虚拟主机是目录式的,如要为index.php为导向转接,(所有的文件都通过mod_rewrite发送到这个文件)可在E:/youdomain.com/document_root添加文件内容为:
RewriteEngine on
RewriteRule !/.(js|gif|jpg|png|css)$ index.php
文件名是.htaccess(注意这就是扩展名)。
更多参考请baidu,google相关httpd.conf .htaccess的设置说明。
xampp Apache Access forbidden! Error 403 解决方法
