我想做的是重写locations文件夹中一堆静态页面的URL,这样
伦敦
映射到物理文件(如果它存在于locations文件夹中),例如。
/地点/伦敦.aspx
是否可以使用URL重写。我不能让规则生效。
<rule name="Rewrite Locations"> <match url="^([_0-9a-z-]+)/*" /> <conditions> <add input="/locations/{REQUEST_FILENAME}.aspx" matchType="IsFile" /> </conditions> <action type="Rewrite" url="/locations/{R:1}.aspx" /> </rule>
多谢,
伊恩
要使isfile工作,您必须传递正确的物理路径,而不是虚拟路径,您可以执行以下操作:
<rule name="Locations" stopProcessing="true"> <match url="^([_0-9a-z-]+)/*" /> <conditions> <add input="{APPL_PHYSICAL_PATH}locations\{R:1}.aspx" matchType="IsFile" /> </conditions> <action type="Rewrite" url="/locations/{R:1}.aspx" /> </rule>