小编don*_*the的帖子

IIS url 重写将所有 .asp 重写为 .html

我需要为 web.config 创建规则,它将所有扩展名为 .html 的文件请求重写为 .asp 并将所有 .asp 请求重定向到 .html

示例:
file_xyz.asp 重写为 file_xyz.html
directory1/file_xyz.asp 重写为 directory1/file_xyz.html

file_xyz.html 重定向到 file_xyz.asp
directory1/file_xyz.html 重定向到 directory1/file_xyz.asp

  1. 规则的语法是什么
  2. 这是一条太宽泛的规则吗?如果我出于什么原因需要拥有诸如 file_abc.html 之类的物理文件,我该如何将其从重定向规则中排除?
  3. 我想我应该只使用 ISAPI_Rewrite http://www.isapirewrite.com/似乎有大量的资源可以使用 htaccess 进行重写,而使用 IIS 7 URL 重写的在线帮助却很少。任何想法和/或建议

提前致谢

到目前为止,这是我对 web.config 的语法

<rule name="RewriteHTMLtoASP" stopProcessing="true">
  <match url="^([^/]+)\.html$" />
  <conditions logicalGrouping="MatchAll" />
  <action type="Rewrite" url="{R:1}.asp" />
  </rule>
 <rule name="RedirectASPtoHTML" stopProcessing="true">
    <match url="^([^/]+)\.asp$" />
     <conditions logicalGrouping="MatchAll">
     <add input="{REQUEST_METHOD}" pattern="^GET$" />
     </conditions>
     <action type="Redirect" url="{R:1}.html" appendQueryString="false" />
   </rule>
Run Code Online (Sandbox Code Playgroud)

asp.net iis iis-7 web-config url-rewriting

0
推荐指数
1
解决办法
1万
查看次数

标签 统计

asp.net ×1

iis ×1

iis-7 ×1

url-rewriting ×1

web-config ×1