【发布时间】:2016-02-19 13:02:36
【问题描述】:
我在 azure 网站上有一个公开的 index.html 页面:
mysite-production.azurewebsites.net
用户可以设置他们的“页面名称”,以便在您访问时
mysite-production.azurewebsites.net/pagename
它显示他们的页面。我正在使用 web.config 中的重写规则来完成此操作。以下是我目前拥有的两条重写规则:
<rule name="Force HTTPS" enabled="true">
<match url="(.*)" ignoreCase="false" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
<rule name="Rewrite to index.html">
<match url="^([0-9a-z]+)+$" />
<action type="Rewrite" url="index.html?id={R:1}" />
</rule>
第一个标准强制 https,第二个允许我动态加载页面。所以当有人去
mysite-production.azurewebsites.net/pagename
他们真的看到了
mysite-production.azurewebsites.net/index.html?id=pagename
这样我可以使用 javascript 来动态更改索引页面。我还有另一个网址:
mysite.org
我指的是天蓝色的网站。我在 mysite.org 上有一个 SSL,因为它的更干净的用户使用这个站点来访问他们的自定义页面。一切都很好。
现在的问题是,我现在有一个希望他们自己的 url 显示他们的自定义页面的第 3 方。他们有一个独特的自定义页面,我们将其称为 custompage,以便用户可以访问:
mysite.org/custompage
并查看他们的自定义页面。他们的 url 是一个通配符子域,基本上看起来像这样:
subdomain.notmysite.org
他们不想要任何重定向。他们只是希望该子域显示 mysite.org/custompage,而其子域显示在地址栏中。我已经创建了 cname 记录并让 subdomain.notmysite.org 指向 mysite-production.azurewebsites.net。所以现在我正在尝试创建一个匹配 subdomain.notmysite.org 的重写规则,显示他们的自定义页面,但将他们的 url 保留在地址栏中。
这是我在其他两条规则之间尝试过的众多规则之一:
<rule name="Notmysite" stopProcessing="false">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^subdomain\.notmysite\.org$"/>
</conditions>
<action type="Rewrite" url="{HTTP_HOST}/custompage" />
</rule>
但我不知道如何让它工作。
【问题讨论】:
标签: .net azure web-config rewrite