端口转发功能
#开启 rewriteengine on rewritecond %{request_method} ^(trace|track) rewriterule .* - [f]
#转发之后地址的域名不转向到ip和端口 #rewritecond %{request_method} !^post$ rewritecond %{http_host} ^xx.com.cn rewriterule ^/(.*) http://xxx.xxx.xxx.xxx:9100/$1 [nc,ne,r=301,p]
#转发之后地址会跳转到ip和端口 rewritecond %{http_host} ^c.xx.com.cn rewriterule ^/(.*) http://xxx.xxx.xxx.xxx:8001/$1 [nc,ne] rewriterule ^/a/b.html http://xxx.xxx.xxx.xxx:8002/a/b.html [nc,p]
#例如 rewriteengine on rewritecond %{request_method} ^(trace|track) rewriterule .* - [f] rewritecond %{http_host} ^m.abc.com.cn rewriterule ^/(.*) http://xxx.xxx.xxx.xxx:8001/$1 [nc,ne] <virtualhost *:8001> documentroot "/var/www/html/mobile" <directory "/var/www/html/mobile"> options followsymlinks includesnoexec indexes directoryindex index.html index.htm index.php allowoverride all order allow,deny allow from all </directory> </virtualhost>
更多apache的相关技术文章,请访问apache教程栏目进行学习!
以上就是apache如何实现域名转发的详细内容。
