apache如何实现域名转发


本文摘自PHP中文网,作者步履不停,侵删。

apache安装后,如果想再添加模块,往往不想重新安装一次,再者,我在安装中发现,并不是安装文件中所有的modules都会被默认安装,这次我添加转发模块的过程中,遇到一些问题,为了以后不走弯路,特地记录下来。

端口转发功能

1

2

3

4

#开启

        RewriteEngine on

        RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)

        RewriteRule .* - [F]

1

2

3

4

#转发之后地址的域名不转向到IP和端口

      #RewriteCond %{REQUEST_METHOD} !^POST$

      RewriteCond %{HTTP_HOST} ^xx.com.cn

      RewriteRule ^/(.*) http://xxx.xxx.xxx.xxx:9100/$1 [NC,NE,R=301,P]

1

2

3

4

#转发之后地址会跳转到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]

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

#例如

      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如何实现域名转发的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

weblogic和Apache区别

Apache怎么读音 是什么

iis和Apache冲突吗

Apache是开源软件吗

查看Apache加载了哪些模块的方法是什么

Apache2.4如何配置https

php如何与Apache连接超时

Apache顶级项目有哪些

怎么看Apache的端口号

解析如何在Apache服务器下设置url访问中文编码

更多相关阅读请进入《Apache》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...