Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.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 如何为仅域请求创建URL重写规则?_Asp.net_.net_Url_Url Rewriting_Url Rewrite Module - Fatal编程技术网

Asp.net 如何为仅域请求创建URL重写规则?

Asp.net 如何为仅域请求创建URL重写规则?,asp.net,.net,url,url-rewriting,url-rewrite-module,Asp.net,.net,Url,Url Rewriting,Url Rewrite Module,我正在尝试为具有多个域的站点创建URL重写。例如,其中一个域是mydomain.com,如果用户将www.mydomain.com放在浏览器中,并且没有指定页面,我希望重写URL以调用www.mydomain.com/landingpage.aspx?cat=1&sol=4 如果用户调用其他任何东西,如www.mydomain.com/somepage.aspx,则应忽略此规则 我已经在我们拥有的Server2008R2机器上安装了URL Rewrite 2.0,并将此规则添加到web.conf

我正在尝试为具有多个域的站点创建URL重写。例如,其中一个域是mydomain.com,如果用户将www.mydomain.com放在浏览器中,并且没有指定页面,我希望重写URL以调用www.mydomain.com/landingpage.aspx?cat=1&sol=4

如果用户调用其他任何东西,如www.mydomain.com/somepage.aspx,则应忽略此规则

我已经在我们拥有的Server2008R2机器上安装了URL Rewrite 2.0,并将此规则添加到web.config

<rewrite>
<rules>
    <rule name="mydomain.com" stopProcessing="true">
        <match url=".*" />
        <conditions>
            <add input="{HTTP_HOST}" pattern="^(www.)?mydomain.com" />
            <add input="{PATH_INFO}" pattern="^$" negate="true" />
        </conditions>
        <action type="Rewrite" url="\landingpage.aspx?cat=1&sol=4" />
    </rule>
</rules>
</rewrite>

我使用的是^$的{PATH_INFO},因此,如果发生了对域的调用以外的任何事情,我认为应该忽略它。但是,它不起作用

我正在网站上使用.NET4.0


有人能告诉我我做错了什么吗?

您正在寻找以下规则:

这将检查URL是否为空,即没有使用匹配URL=^$-空字符串指定页面,并重定向到特定页面

<rule name="Redirect to specific page" enabled="true" stopProcessing="true">
   <match url="^$" />
   <conditions>
        <add input="{HTTP_HOST}" pattern="^(www.)?mydomain.com$" />
   </conditions>
   <action type="Redirect" url="http://{HTTP_HOST}/landingpage.aspx?cat=1&sol=4" />
</rule>