重写外部子域

Rewrite external subdomain

我在 Azure 网站上有一个 public index.html 页面:

我的网站-production.azurewebsites.net

用户可以设置他们的 "page name" 这样当您访问

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 动态更改该索引页。我还有一个 url:

mysite.org

我指着天蓝色的网站。我在 mysite.org 上有一个 SSL,因为它的清洁用户使用这个网站去他们的自定义页面。一切都很好。

现在的问题是我现在有一个第 3 方想要他们自己的 url 来显示他们的自定义页面。他们有一个独特的自定义页面,我们称之为 custompage,以便用户可以访问:

我的网站。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>

但我不知道如何让它工作。

能够修复它。问题出在 "match url" 部分。当我需要检查的是主机后的路径为空时,我正在匹配任何 url。这是工作解决方案。

<rule name="Notmysite" stopProcessing="true">
      <match url="^$" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^(www.)?subdomain\.notmysite\.org$" />  
      </conditions>
      <action type="Rewrite" url="index.html" />
    </rule>

所以现在,如果www.subdomain.notmysite.orgsubdomain.notmysite.org访问我的网站都将它们重写到索引页并根据 url.

生成内容