简体   繁体   English

IIS URL重写以访问子文件夹内容

[英]IIS URL rewrite to access subfolder content

Is it possible to create a URL rewrite that places the content of a subfolder in the root? 是否可以创建将子文件夹的内容放在根目录中的URL重写?

Example: 例:

/pages/article1 would be reached from /article1 可以从/ article1到达/ pages / article1

/pages/otherstuff would be reached from /otherstuff 可以从/ otherstuff到达/ pages / otherstuff

I don't want to use virtual directories, because we're talking about hundreds of static pages in the /pages folder. 我不想使用虚拟目录,因为我们正在谈论/ pages文件夹中的数百个静态页面。

I found the answer myself... This did the trick: 我自己找到了答案。

<rule name="RemoveSEOFolder" stopProcessing="true">
    <match url="^seo$|^seo/(.*)$" />
    <conditions>
    </conditions>
    <action type="Redirect" url="seo/{R:1}" />
</rule>
<rule name="RewriteToFile">
    <match url="^(?!seo/)(.*)" />
    <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
    <action type="Rewrite" url="seo/{R:1}" />
</rule>

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

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