我一直在研究一个小型链接长度抑制器站点,但似乎无法在 IIS7 上弄清楚。我习惯于使用 isapi rewrite 和 mod_rewrite。
以下场景处于活动状态:
假设我有 test.com,这是主域。域应该正常处理所有文件。但是当/.*它既不是目录也不是文件时,它应该将它发送到redirect.asp?text=(.*).
这就是我的 web.config 的样子
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
    <rewrite>
    <rules>
        <rule name="YOURLS 1" stopProcessing="true">
            <match url="^([0-9A-Za-z-]+)$" ignoreCase="false" />
            <conditions logicalGrouping="MatchAll">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            </conditions>
            <action type="Rewrite" url="redirect.asp?test={R:1}" appendQueryString="false" />
        </rule>
    </rules>
    </rewrite>
</system.webServer>