ASP.NET MVC 5で記述されたWebアプリケーションがあります。このアプリケーションにはユーザーに関する情報が含まれています。今度は、自分のウェブサイトのサブドメインとしてアクセス可能な各ユーザーのプロフィールページを作成したいと考えています(例:user1.example.com
、user2.example.com
、...)。ASP.NET URL MVC 5のサブドメインルーティングのIIS URL書き換えルール
これらのサブドメインにはHTTP経由でアクセスできますが、残りのアプリケーションではHTTPSを使用する必要があります。
IIS上でWebアプリケーションを実行するので、URL書き換えルールを使用してuser1.example.com
からexample.com/Profile/Index?name=user1
に書き換えた場合には最適であると判断したので、Webアプリケーション自体は使用されているサブドメインについて知る必要はありません。私はこれらの書き換えルールを思い付いた:
<rewrite>
<rules>
<clear />
<rule name="Rewrite user subdomains into query string" stopProcessing="true">
<match url="^(.+)" />
<conditions>
<add input="{HTTP_HOST}" negate="true" pattern="^www\.example\.com$" />
<add input="{HTTP_HOST}" pattern="^([^.]+)\.example\.com$" />
</conditions>
<action type="Rewrite" url="/Profile/Index?name={C:1}" />
</rule>
<rule name="Redirect to https without www" stopProcessing="true">
<match url="(.*)" />
<conditions trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^www\.example\.com$" />
<add input="{HTTP_HOST}" pattern="^example\.com$" />
</conditions>
<action type="Redirect" url="https://example.com/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
このコードは、残念ながらも、user1.example.com
上example.com/Profile/Index?name=user1
と力HTTPSにuser1.example.com
を書き換えません。
誰かが私に理由とその理由を説明してくれますか?