本文介绍了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.)


    在INBOUND RULES下,选择BLANK RULE
    给它起一个名字,你想要的任何名字(即Subdirectory Rewrite)
    在PATTERN下,键入 ^ web2 $ | ^ web2 /(.*)
    在条件下,单击添加
    条件输入: {HTTP_HOST}
    模式: ^ web1.com $
    在ACTION下,选择操作类型:重写
    重写网址: {R:1}
    点击申请
    Under INBOUND RULES, select BLANK RULEGive it a name, any name you want (ie, "Subdirectory Rewrite")Under PATTERN, type ^web2$|^web2/(.*)Under CONDITION, click ADDCondition Input: {HTTP_HOST} Pattern: ^web1.com$Under ACTION, select Action Type: RewriteRewrite URL: http://www.web2.com/{R:1}Click APPLY






ON WEB1 SERVER (在IIS6上):

使用


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






ON WEB2 SERVER (在IIS8上):

在网站级别,添加OUTBOUND RULE。

On the site level, add OUTBOUND RULE.


    在OUTBOUND RULES下,选择BLANK RULE
    Give它是一个名字,你想要的任何名字(即重写路径)
    在PRECONDITION下,选择创建新的前提条件
    名称: isHTHML
    点击添加
    条件输入: {RESPONSE_CONTENT_TYPE}
    模式: ^ text / html
    在MATCH下,选中匹配内容
    模式: ^ /(。*)
    在ACTION下,操作类型:重写
    值: / web2 / {R:1}

    点击申请

    Under OUTBOUND RULES, select BLANK RULEGive it a name, any name you want (ie, "Rewrite Path")Under PRECONDITION, select Create New PreconditionName: isHTHMLClick ADDCondition Input: {RESPONSE_CONTENT_TYPE}Pattern: ^text/htmlUnder MATCH, select all the checkboxes under "Match the content within"Pattern: ^/(.*)Under ACTION, Action Type: RewriteValue: /web2/{R:1}

    Click APPLY

PS:感谢Scott Forsyth的灵感。

PS: Thanks to Scott Forsyth for the inspiration.

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

07-03 21:35