Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.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
C# asp.net重写规则中的重写和重定向_C#_.net_Url Rewriting - Fatal编程技术网

C# asp.net重写规则中的重写和重定向

C# asp.net重写规则中的重写和重定向,c#,.net,url-rewriting,C#,.net,Url Rewriting,我真的很难理解重写规则,为什么我的规则不能像我期望的那样 我有两条规则,基本上我需要实现的是,它会拾取我的漂亮URL,而不考虑子目录,然后重定向到特定文件夹。然后,这将使用一个id,该id在pretty URL中指定,然后在我的解决方案中点击相应的页面 因此,这个规则应该能够获取漂亮URL之前的任何内容,然后从根目录重定向到文件夹/gen1/ <rule name="PokemonGen1Rule 1"> <match url="^gen1-[\w-]*[^?]*-pk

我真的很难理解重写规则,为什么我的规则不能像我期望的那样

我有两条规则,基本上我需要实现的是,它会拾取我的漂亮URL,而不考虑子目录,然后重定向到特定文件夹。然后,这将使用一个id,该id在pretty URL中指定,然后在我的解决方案中点击相应的页面

因此,这个规则应该能够获取漂亮URL之前的任何内容,然后从根目录重定向到文件夹/gen1/

<rule name="PokemonGen1Rule 1">
    <match url="^gen1-[\w-]*[^?]*-pkmid([\d]+)\.html" ignoreCase="true" />
    <action type="Redirect" url="^/gen1/{R:0}" />
</rule>

然后,此规则应在url到达gen1文件夹时捕获该url,并使用包含在pretty url中的id,将其作为参数传递给pokemon.aspx页面

<rule name="PokemonGen1Rule 2">
    <match url="^gen1/gen1-[\w-]*[^?]*-pkmid([\d]+)\.html" ignoreCase="true" />
    <action type="Rewrite" url="/gen1/pokemon.aspx?pkmid={R:1}" 
    appendQueryString="false" logRewrittenUrl="true" />
</rule>

它不起作用,但在我的大脑里,我无法找出什么东西坏了。我试过各种不同的组合来放置V形,等等,但都不起作用

如有任何建议,将不胜感激


<rule name="PokemonGen1Rule 1" stopProcessing="true">
    <match url="[\w-]*[^?]*/(gen1-[\w-]*[^?]*-pkmid([\d]+)\.html)" 
    ignoreCase="true" />
       <conditions>
         <add input="{REQUEST_URI}" negate="true" 
           pattern="/gen1/gen1-[\w-]*[^?]*-pkmid([\d]+)\.html" 
           ignoreCase="true" />
       </conditions>
   <action type="Redirect" url="/gen1/{R:1}" />
</rule>
<rule name="PokemonGen1Rule 2" stopProcessing="true">
    <match url="[\w-]*[^?]*/gen1-[\w-]*[^?]*-pkmid([\d]+)\.html" 
    ignoreCase="true" />
     <action type="Rewrite" url="/gen1/pokemon.aspx?pkmid={R:1}" 
     appendQueryString="false" logRewrittenUrl="true" />
</rule>
解决了