开发者

Redirect home page

What I want is to redirect poo.example.com to poo.example.com/home.ashx but I am failing with the following code;

<rewrite>
  <rules>
    <rule name="Redirect to HTTPS" stopProcessing="true">
      <match url="(.*)" />
      <cond开发者_StackOverflowitions>
        <add input="{HTTPS}" pattern="^OFF$" />
      </conditions>
      <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
    </rule>
    <rule name="Redirect poo.example.com to poo.example.com/home.ashx" patternSyntax="ECMAScript" stopProcessing="true">
      <match url="(./)" />
      <action type="Redirect" url="https://{HTTP_HOST}/home.ashx" />
    </rule>
  </rules>
</rewrite>

I am on IIS 7.5.

NOTE

I tired using default document but it didn't work. My app is an asp.net mvc app. It could be related to that but this is not an issue here. I need to implement that with IIS URL Rewrite feature.


You could just add home.ashx as a default document in IIS (make sure it appears at the top of the list), then you wouldn't need do to any URL rewriting.


This will rewrite (internal redirect when URL will remain unchanged in browser):

<rule name="home.ashx" stopProcessing="true">
    <match url="^$" />
    <action type="Rewrite" url="/home.ashx" />
</rule>

This will redirect (301 Permanent Redirect):

<rule name="home.ashx" stopProcessing="true">
    <match url="^$" />
    <action type="Redirect" url="/home.ashx" />
</rule>

Because domain names are the same in source and target URLs (poo.example.com) there is no real need of specifying it in the rule -- IIS will put current domain automatically.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜