私は私のASP.NET MVC 5プロジェクトのweb.config
で次の書き換えルールがあります。「非WWW WWWへ」と「https」のASP.NET MVCをlocalhostのweb.configファイル内のルールを書き換えなく
<rule name="Redirect example.com to www.example.com and enforce https" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^[^www]" />
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://www.example.com/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
を
ルールはwww以外のものをwwwとhttpをhttpsにリダイレクトします(http://example.com/hey
はhttps://www.example.com/hey
にリダイレクトされます)。正常に動作します。しかし、それはまたlocalhost
で動作し、私はそれを回避することができないようです - 私は否定規則と正規表現を試してみました|
が含まれていますが、正しい組み合わせを見つけることができないようです。私はこれに間違った方法で近づいていますか?
おかげで、私はライブサイト上のChromeでこれを取得しています:「www.example.comあなたはあまりにも多くのリダイレクトFirefoxのように – globetrotter
@globetrotter私はそれが 'MatchAny'の問題だと思っています - ' MatchAll'で更新された答えが – dotnetom
に役立つかどうか確認してください。ライブサイトでは動作しますが、 'localhostに' https'を追加しようとします。 ' – globetrotter