拜托,我有这个文件夹:
root/teste_seo/script.asp
而不是使用网址:
www.mysite.com/teste_seo/script.asp
我需要使用 IIS 重写的这个 url:
www.mysite.com/script.asp
我尝试使用此链接中的规则,但没有奏效:
请问这个规则怎么写?
PS.: 对于 teste_seo 文件夹中的任何 *.asp 文件。
以下规则应该可以解决问题:
<rule name="teste_seo" stopProcessing="true">
<match url="^script.asp" />
<action type="Rewrite" url="/teste_seo/script.asp" />
</rule>
然后只需链接到 www.mysite.com/script.asp
在 OP 评论后编辑:
如果是这样,只要您在文档的根目录中有脚本文件的副本,就可以使用以下规则:
<rule name="teste_seo" stopProcessing="true">
<match url="^teste_seo/([^\.]+\.asp)" />
<action type="Redirect" url="/{R:1}" />
</rule>
如果您需要所有脚本文件都指向同一个,您可以使用:
<rule name="teste_seo" stopProcessing="true">
<match url="^teste_seo/([^\.]+\.asp)" />
<action type="Redirect" url="/script.asp" />
</rule>
澄清后再次编辑:
这 2 条规则应该是您需要的修复:
<rule name="teste_seo_redirect" stopProcessing="true">
<match url="^teste_seo/([^\.]+\.asp)" />
<action type="Redirect" url="/{R:1}" />
</rule>
<rule name="teste_seo_rewrite" stopProcessing="true">
<match url="^([^\.]+\.asp)" />
<action type="Rewrite" url="/teste_seo/{R:1}" />
</rule>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句