IIS7 URL从默认网站

时间:2018-03-18 10:56:54

标签: iis url-rewriting arr

使命:
通过我的家庭服务器上的主网站通过IIS URL重写/ ARR访问我的家庭路由器的Web管理站点。因此,我没有输入http://192.168 /index.cgi来访问我的路由器,而是可以访问我的主页http://example.com/index.html,然后点击链接转到http://example.com/router1/index.cgi

旅程
到目前为止,我已经能够以多种方式重定向和重写。但是,只有在URL中不使用“子文件夹”时才会成功。我发现这是由于路由器的网站使用根相对链接。我试图写一些出站规则来解决这个问题,但是我没有成功。当我使用一个小正则表达式来剥离这样的第一个正斜杠

(用等号和引号替换等号,双引号或单引号,正斜杠)

        <outboundRules>
            <rule name="gallifrey-out" preCondition="IsHTML">
                <match filterByTags="None" customTags="" pattern="=(\&quot;|\')\/" />
                <action type="Rewrite" value="={R:1}" />
            </rule>
            <preConditions>
                <remove name="IsHTML" />
                <preCondition name="IsHTML">
                    <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                </preCondition>
            </preConditions>
        </outboundRules>

所有图片都正确显示,但指向页面的链接仍然缺少“router1”子文件夹部分,因此会抛出404(未找到)错误。

我曾在某处读过基本标签可以解决这个问题。看到URL重写没有基本标签来查找和重写,我尝试通过样式标签将其注入页面,如此

        <outboundRules>
            <rule name="gallifrey-out" preCondition="IsHTML" stopProcessing="true">
                <match filterByTags="CustomTags" customTags="baseInject" pattern="(.*)" />
                <action type="Rewrite" value="text/css&quot;>&lt;/style>&lt;base href=&quot;http://example.com/router1/images&quot;>&lt;style type=&quot;text/css" />
            </rule>
            <preConditions>
                <remove name="IsHTML" />
                <preCondition name="IsHTML">
                    <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                </preCondition>
            </preConditions>
            <customTags>
                <tags name="baseInject">
                    <tag name="style" attribute="type" />
                </tags>
            </customTags>
        </outboundRules>

可悲的是,这也没有用,就像....根本没有。它确实注入了,这里是源代码

Source code screenshot

在过去的几天里,我看了很多关于如何实现这一目标的网站和视频。虽然我在这个过程中学到了很多东西,但我仍然无法完成这项工作。其他人似乎都有不同的方式去做。最终我将在主服务器上使用它,并且需要在我家外面访问它,这意味着页面呈现给客户端的方式需要可以从公共网络路由。

测试台
一台非常老的Sony VIAO笔记本电脑,运行带有IIS7的Win7 Ultimate 采用Verizon / Frontier固件的ActionTec MI424WR rev i

Do not Wannas:
不想在路由器上向公众开放另一个端口
不想再购买另一个域名
不想购买通配符SSL证书(只有一个)

重大问题
有没有人知道在使用url rewrite重定向时如何解决根相对超链接?

0 个答案:

没有答案