Apache伺服器的URL重新導向

來源:互聯網
上載者:User

標籤:

前端時間要整個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重新導向

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.