Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 重定向主页_Asp.net_Regex_Iis_Iis 7_Url Rewriting - Fatal编程技术网

Asp.net 重定向主页

Asp.net 重定向主页,asp.net,regex,iis,iis-7,url-rewriting,Asp.net,Regex,Iis,Iis 7,Url Rewriting,我想要的是将poo.example.com重定向到poo.example.com/home.ashx,但是我的以下代码失败了 <rewrite> <rules> <rule name="Redirect to HTTPS" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" p

我想要的是将
poo.example.com
重定向到
poo.example.com/home.ashx
,但是我的以下代码失败了

<rewrite>
  <rules>
    <rule name="Redirect to HTTPS" stopProcessing="true">
      <match url="(.*)" />
      <conditions>
        <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>

我在IIS 7.5上

注意


我厌倦了使用默认文档,但它不起作用。我的应用程序是asp.net mvc应用程序。这可能与此有关,但这不是一个问题。我需要使用IIS URL重写功能来实现这一点。

您可以将
home.ashx
添加为IIS中的默认文档(确保它出现在列表的顶部),这样您就不需要进行任何URL重写。

这将重写(当URL在浏览器中保持不变时,内部重定向):


这将重定向(301永久重定向):



因为域名在源URL和目标URL(
poo.example.com
)中是相同的,所以没有必要在规则中指定它——IIS将自动放置当前域。

尝试过,但没有成功。我的应用程序是一个asp.net mvc应用程序,我想默认文档因此不起作用。如果您直接请求
/home.ashx
,它能起作用吗?检查您的某个路由是否正在接收请求,如果是,请尝试在映射其他路由之前忽略对
.ashx
文件的请求:
IgnoreRoute(“{handler}.ashx?{*path}”)是的,它很有效。你没有明白我的问题。我需要一个正则表达式代码来获取匹配节点内的主机url帮助?
<rule name="home.ashx" stopProcessing="true">
    <match url="^$" />
    <action type="Rewrite" url="/home.ashx" />
</rule>
<rule name="home.ashx" stopProcessing="true">
    <match url="^$" />
    <action type="Redirect" url="/home.ashx" />
</rule>