简体   繁体   English

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

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

Please, I have this folder: 拜托,我有这个文件夹:

root/teste_seo/script.asp

Instead to use the url: 而是使用url:

www.mysite.com/teste_seo/script.asp

I need this url using IIS rewrite: 我需要使用IIS重写此URL:

www.mysite.com/script.asp

I try to use the rule from this link but didn't work: 我尝试使用此链接中的规则,但不起作用:

IIS 7.5 URL Rewrite - Rewrite a Folder from an URL IIS 7.5 URL重写-从URL重写文件夹

Please, how can I write this rule? 拜托,我该怎么写这个规则?

PS.: For any *.asp file inside teste_seo folder. PS .:适用于teste_seo文件夹中的任何* .asp文件。

The following rule should do the trick: 以下规则可以解决问题:

<rule name="teste_seo" stopProcessing="true">
    <match url="^script.asp" />
    <action type="Rewrite" url="/teste_seo/script.asp" />
</rule>

Then just link to the www.mysite.com/script.asp 然后只需链接到www.mysite.com/script.asp

Edited after comment from OP: 在OP评论后编辑:

If so you can use the following rule as long as you have a copy of the script files in the root of your document: 如果是这样,只要您在文档的根目录中有脚本文件的副本,就可以使用以下规则:

<rule name="teste_seo" stopProcessing="true">
    <match url="^teste_seo/([^\.]+\.asp)" />
    <action type="Redirect" url="/{R:1}" />
</rule>

And if you need all script files to point to the same one you can use: 如果您需要所有脚本文件指向同一脚本文件,则可以使用:

<rule name="teste_seo" stopProcessing="true">
    <match url="^teste_seo/([^\.]+\.asp)" />
    <action type="Redirect" url="/script.asp" />
</rule>

Edited again after clarification: 澄清后再次编辑:

These 2 rules should then be the fix you need: 然后,以下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