Asp.net IIS URL重写动态文件夹数
我必须创建一个重写规则,捕获旧商店系统中的所有URL,并将它们重定向到新商店。问题如下: 旧商店的源URL可以包含找到产品编号的路径,如下所示:Asp.net IIS URL重写动态文件夹数,asp.net,iis,Asp.net,Iis,我必须创建一个重写规则,捕获旧商店系统中的所有URL,并将它们重定向到新商店。问题如下: 旧商店的源URL可以包含找到产品编号的路径,如下所示:www.domain.com/folder1/folder2/folder3/[product number]。html folder1、folder2和folder3可以,但不需要位于被调用的URL中。它们也不是固定的(例如folder1可以是“汽车”或“自行车”或“服务”)。链接也可以是仅www.domain.com/folder1/[product
www.domain.com/folder1/folder2/folder3/[product number]。html
folder1、folder2和folder3可以,但不需要位于被调用的URL中。它们也不是固定的(例如folder1可以是“汽车”或“自行车”或“服务”)。链接也可以是仅www.domain.com/folder1/[product number].html
,有时甚至是www.domain.com/[product number].html
对于新系统,我只需要目标URL中的[product number]。应该是这样的:www.domain.com/path1/path2/[product number].aspx
我在Google或Stackoverflow中找不到任何帮助我解决这个问题的东西
提前谢谢
丹尼尔这应该是可行的:
<system.webServer>
<rewrite>
<rules>
<rule name="Three deep" stopProcessing="true">
<match url=".*/.*/.*/(.*?).html" />
<action type="Redirect" url="/path1/path2/{R:1}.aspx" />
</rule>
<rule name="Two deep" stopProcessing="true">
<match url=".*/.*/(.*?).html" />
<action type="Redirect" url="/path1/path2/{R:1}.aspx" />
</rule>
<rule name="One deep" stopProcessing="true">
<match url=".*/(.*?).html" />
<action type="Rewrite" url="/path1/path2/{R:1}.aspx" />
</rule>
<rule name="None deep" stopProcessing="true">
<match url="(.*?).html" />
<action type="Rewrite" url="/path1/path2/{R:1}.aspx" />
</rule>
</rules>
</rewrite>
</system.webServer>
我担心我用于产品代码的表达式-(.*)
-过于笼统,但我不知道您的产品代码的结构。如果你能把它收紧,那就更好了
我还担心它们会影响非产品的内容(如分类和搜索),因此如果所有产品URL都使用一个轴心点,我建议使用它。收紧产品代码位也可能有助于错误匹配
目前,它正在处理.html与.aspx之间的代码,而不是将其发送到重定向螺旋中
我可能可以用一个更好的正则表达式在更少的规则下完成它,今晚我将举行一次狂欢。这应该可以:
<system.webServer>
<rewrite>
<rules>
<rule name="Three deep" stopProcessing="true">
<match url=".*/.*/.*/(.*?).html" />
<action type="Redirect" url="/path1/path2/{R:1}.aspx" />
</rule>
<rule name="Two deep" stopProcessing="true">
<match url=".*/.*/(.*?).html" />
<action type="Redirect" url="/path1/path2/{R:1}.aspx" />
</rule>
<rule name="One deep" stopProcessing="true">
<match url=".*/(.*?).html" />
<action type="Rewrite" url="/path1/path2/{R:1}.aspx" />
</rule>
<rule name="None deep" stopProcessing="true">
<match url="(.*?).html" />
<action type="Rewrite" url="/path1/path2/{R:1}.aspx" />
</rule>
</rules>
</rewrite>
</system.webServer>
我担心我用于产品代码的表达式-(.*)
-过于笼统,但我不知道您的产品代码的结构。如果你能把它收紧,那就更好了
我还担心它们会影响非产品的内容(如分类和搜索),因此如果所有产品URL都使用一个轴心点,我建议使用它。收紧产品代码位也可能有助于错误匹配
目前,它正在处理.html与.aspx之间的代码,而不是将其发送到重定向螺旋中
我可能可以用一个更好的正则表达式在更少的规则中完成这项工作,今晚我将举行一个聚会。产品编号总是数字的吗?不,产品编号是字母数字的,可以包含-和u字符folder1、folder2和path1、path2之间的关系是什么?路径是否也是动态的?第1-3页描述了旧magento商店中使用的产品目录路径。我在新的商店系统和URL中不再需要它们。如果我在(旧站点)
www.domain.com/folder1/folder2/[product number].html
如何知道将用户重新定向到的www.domain.com/path1/path2/[product number].aspx
?产品编号是否始终是数字?否,产品编号为字母数字,可以包含-和u字符folder1、folder2和path1、path2之间的关系是什么?路径是否也是动态的?第1-3页描述了旧magento商店中使用的产品目录路径。我在新的商店系统和URL中不再需要它们。如果我在(旧站点)www.domain.com/folder1/folder2/[product number].html
如何知道将用户重新定向到哪个版本的www.domain.com/path1/path2/[product number].aspx
?