前端时间要整个Apache重定向功能,在此记录一下。
一、安装Apache
Windows版本官方下载安装文件httpd-2.2.21-win32-x86-openssl-0.9.8r,选择安装目录,直接安装就好。
安装完后,Services 和 任务栏会有Apache的服务出现。
二、Apache目录结构
主要是conf配置信息文件夹和modules功能模块文件夹。
主要的配置文件:
C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\httpd.conf,
C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\extra\httpd-vhosts.conf。
三、开启虚拟主机配置
修改以下配置,可以在httpd-vhosts.conf中添加不同的主机
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
<VirtualHost *:8080> ServerAdmin webmaster@dummy-host.englishnet DocumentRoot "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs" ServerName dummy-host.englishnet ServerAlias www.dummy-host.englishnet ErrorLog "logs/dummy-host.englishnet-error.log" CustomLog "logs/dummy-host.englishnet-access.log" common RewriteEngine ON RewriteRule /index3.html http://passport.cnblogs.com/user/signin [R] </VirtualHost> <VirtualHost *:8090> ServerAdmin webmaster@dummy-host2.englishnet DocumentRoot "E:/ASoft/Apache/ApacheTest" AspNetMount / "E:/ASoft/Apache/ApacheTest" ServerName dummy-host2.englishnet ErrorLog "logs/dummy-host2.englishnet-error.log" CustomLog "logs/dummy-host2.englishnet-access.log" common <Directory "E:/ASoft/Apache/ApacheTest"> Options FollowSymlinks ExecCGI Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Order allow,deny Allow from all DirectoryIndex Default.aspx index.html </Directory> RewriteEngine ON RewriteRule ^/postdata.ashx$ http://testbx.palmyou.com/v7s-insurance-wap/individualend/meiyawxpay [R,P] #/RevertData.ashx </VirtualHost>