繁体   English   中英

IIS重写-从URL删除真实文件夹

[英]IIS Rewrite - Remove real folder from the URL

拜托,我有这个文件夹:

root/teste_seo/script.asp

而是使用url:

www.mysite.com/teste_seo/script.asp

我需要使用IIS重写此URL:

www.mysite.com/script.asp

我尝试使用此链接中的规则,但不起作用:

IIS 7.5 URL重写-从URL重写文件夹

拜托,我该怎么写这个规则?

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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM