使用Web平台安装程序,安装Url重写工具2.0

使用GUI添加规则

URL重写 -> 添加规则 -> 空白规则

1
2
3
4
5
6
7
8
请求的URL:与模式不匹配
使用:正则表达式
忽略大小写 选择
模式:.+\.[a-zA-Z]+
操作类型:重写
重写URL:/
附加查询字符串 选择
停止处理后续规则 选择

或者在站点根目录添加配置文件 web.config

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="index" stopProcessing="true">
                    <match url=".+\.[a-zA-Z]+" negate="true" />
                    <action type="Rewrite" url="/" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>