使用IIS URL Rewite摆脱URL中的子文件夹名称

问题描述 投票:-1回答:1

我当前的网址看起来像:http://www.example.com/files/maps.html

我希望它看起来像:http://www.example.com/maps.html

[基本上,我只是想摆脱URL的“ / files /”部分。我正在使用IIS URL重写模块,但不熟悉它,也不熟悉reg表达式。

regex iis url-rewriting url-rewrite-module
1个回答
0
投票

您可以尝试使用以下规则:

<rewrite>
        <rules>
            <clear />

            <rule name="Removefoldername" stopProcessing="true">
                <match url="^abc$|^abc/page1.html$" />
                <conditions>
                </conditions>
                <action type="Redirect" url="page1.html" />
            </rule>
            <rule name="RewriteToFile">
                <match url="^(?!abc/)page1.html" />
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                </conditions>
                <action type="Rewrite" url="abc/page1.html" />
            </rule>
        </rules>

    </rewrite>
© www.soinside.com 2019 - 2024. All rights reserved.