標籤:
前端時間要整個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 [email protected] 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 [email protected] 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>
View Code
四、Apache對Asp.net的支援
2.2以下版本需要安裝.net功能模組mod_aspdotnet-2.2.0.2006-setup-r2,這個模組支援.net 4以下的版本。
需要在httpd.conf添加以下的aspdotnet_module的配置:
#asp.netLoadModule aspdotnet_module "modules/mod_aspdotnet.so"AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj licx rem resources resx soap vb vbproj vsdisco webinfo<IfModule mod_aspdotnet.cpp># Mount the ASP.NET example application#AspNetMount /active "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs"# Map all requests for /active to the application files#Alias /active "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs"# Allow asp.net scripts to be executed in the active example#<Directory "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs">#Options FollowSymlinks ExecCGI#Order allow,deny#Allow from all#DirectoryIndex Default.htm Default.aspx#</Directory># For all virtual ASP.NET webs, we need the aspnet_client files# to serve the client-side helper scripts.AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) "C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"<Directory "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">Options FollowSymlinksOrder allow,denyAllow from all</Directory></IfModule>
View Code
五、重新導向功能
開啟代理Module:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
POST重新導向P、URL重新導向R:
RewriteEngine ON
RewriteRule ^/postdata.ashx$ http://www.aaaa.com/v7s-wap/individualend/ddddd [R,P]
反向 Proxy:
#反向 Proxy設定
ProxyPass /proxy http://www.proxypass.com/proxy
ProxyPassReverse /proxy http://www.proxypass.com/proxy
Apache伺服器的URL重新導向