URL使用IIS将子目录重写到其他域 [英] URL Rewrite of a subdirectory to a different domain using IIS

查看:584
本文介绍了URL使用IIS将子目录重写到其他域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标#1:www.web1.com/web2需要指向www.web2.com

GOAL #1: www.web1.com/web2 needs to point to www.web2.com

目标#2:用户必须始终看到www.web1。 com / web2和路径& web2中的查询

GOAL #2: Users must always see www.web1.com/web2 and the paths & queries in web2

例如:www.web1.com/web2/login或www.web1.com/web2/?query=string

For example: www.web1.com/web2/login OR www.web1.com/web2/?query=string

www.web1.com在IIS6上(使用ISAPI重写)
www.web2.com在IIS8上(使用URL Rewrite& ARR)

www.web1.com is on IIS6 (using ISAPI Rewrite) www.web2.com is on IIS8 (using URL Rewrite & ARR)

有人可以指导我如何解决这个问题吗?

Can someone guide me on how I should go about this?

================= ======

=======================

在web1上,我使用了以下内容:

On web1, I used the following:

RewriteCond%{HTTP_HOST} ^ www.web1.com $

RewriteCond %{HTTP_HOST} ^www.web1.com$

RewriteRule ^ / web2 /?$ www.web2.com [NC,P,R = 301,L]

RewriteRule ^/web2/?$ www.web2.com [NC,P,R=301,L]

在web2上,我设置了ARR服务器场并创建了入站规则。

On web2, I setup an ARR server farm and have created an inbound rule.

但是,当我拉出www.web1.com/web2时,浏览器上的URL仍然是www.web2.com。我玩过REVERSE PROXY和OUTBOUND。我已经看过Scott Forsyth视频的大多数,并阅读了他的文章。我觉得我正在跳过某些东西。

However, when I pull www.web1.com/web2, the URL on the browser still says www.web2.com. I've played around with using the REVERSE PROXY and the OUTBOUND. I've watched most of Scott Forsyth's videos and read his articles. I feel I'm skipping something.

推荐答案

在IIS7和IIS8上使用URL REWRITE进行计算。 (我今天将在IIS6上的ISAPI REWRITE上应用它并将更新我的帖子。)

Figured it out using URL REWRITE on IIS7 and IIS8. (I will apply this on the ISAPI REWRITE on IIS6 today and will update my post.)

ON WEB1服务器(在IIS7上):

在网站级别,添加INBOUND RULE。 (对于新手,运行IIS并单击我的WEB1版本。双击右侧图标列表中的URL REWRITE。单击右侧列表中的ADD RULE。)

On the site level, add INBOUND RULE. (For newbies, run IIS and click on your version of my WEB1. Double-click on URL REWRITE from the list of icons on the right. Click on ADD RULE from the list on the right.)


  1. 在INBOUND RULES下,选择BLANK RULE

  2. 给它起一个名字,你想要的任何名字(即Subdirectory Rewrite)

  3. 在PATTERN下,键入 ^ web2 $ | ^ web2 /(.*)

  4. 在条件下,单击添加

  5. 条件输入: {HTTP_HOST}

  6. 模式: ^ web1.com $

  7. 在ACTION下,选择操作类型:重写

  8. 重写网址: http://www.web2.com/ {R:1}

  9. 点击申请

  1. Under INBOUND RULES, select BLANK RULE
  2. Give it a name, any name you want (ie, "Subdirectory Rewrite")
  3. Under PATTERN, type ^web2$|^web2/(.*)
  4. Under CONDITION, click ADD
  5. Condition Input: {HTTP_HOST}
  6. Pattern: ^web1.com$
  7. Under ACTION, select Action Type: Rewrite
  8. Rewrite URL: http://www.web2.com/{R:1}
  9. Click APPLY






ON WEB1 SERVER (在IIS6上):

使用 Helicon ISAPI_Rewr第3版 付费版


  1. RewriteCond主持人:(。*)

  2. RewriteRule ^ / web2(/.*)?$ http://www.web1.com/web2 $ 1 [P]

  1. RewriteCond Host: (.*)
  2. RewriteRule ^/web2(/.*)?$ http://www.web1.com/web2$1 [P]






ON WEB2 SERVER (在IIS8上):

在网站级别,添加OUTBOUND RULE。

On the site level, add OUTBOUND RULE.


  1. 在OUTBOUND RULES下,选择BLANK RULE

  2. Give它是一个名字,你想要的任何名字(即重写路径)

  3. 在PRECONDITION下,选择创建新的前提条件

  4. 名称: isHTHML

  5. 点击添加

  6. 条件输入: {RESPONSE_CONTENT_TYPE}

  7. 模式: ^ text / html

  8. 在MATCH下,选中匹配内容
  9. 模式: ^ /(。*)
  10. 在ACTION下,操作类型:重写

  11. 值: / web2 / {R:1}

  12. 点击申请

  1. Under OUTBOUND RULES, select BLANK RULE
  2. Give it a name, any name you want (ie, "Rewrite Path")
  3. Under PRECONDITION, select Create New Precondition
  4. Name: isHTHML
  5. Click ADD
  6. Condition Input: {RESPONSE_CONTENT_TYPE}
  7. Pattern: ^text/html
  8. Under MATCH, select all the checkboxes under "Match the content within"
  9. Pattern: ^/(.*)
  10. Under ACTION, Action Type: Rewrite
  11. Value: /web2/{R:1}
  12. Click APPLY

PS:感谢Scott Forsyth的灵感。

PS: Thanks to Scott Forsyth for the inspiration.

这篇关于URL使用IIS将子目录重写到其他域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆