繁体   English   中英

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

[英]IIS URL rewrite to access subfolder content

是否可以创建将子文件夹的内容放在根目录中的URL重写?

例:

可以从/ article1到达/ pages / article1

可以从/ otherstuff到达/ pages / otherstuff

我不想使用虚拟目录,因为我们正在谈论/ pages文件夹中的数百个静态页面。

我自己找到了答案。

<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