【问题标题】:Remove file extensions in URL asp.net删除 URL asp.net 中的文件扩展名
【发布时间】:2012-11-09 06:52:41
【问题描述】:

我目前正在我的网站中使用 URL 重写。

如果网址是www.mywebsite.com/orders/Default.aspx?id=100

它将网址设为www.mywebsite.com/orders/100

如果有人试图破解 URL 并输入未知值,我会重定向到主页

现在我需要的是,如果有人试图破解 URL 并添加诸如 .aspx.jsp.html.html 之类的扩展名,...

例如:www.mywebsite.com/orders/100.aspx(黑客攻击后)。

我想删除这些扩展名并将查询字符串作为www.mywebsite.com/orders/100 并处理它。

我在 StackOverflow 中看到了这种行为。

我能做到这一点吗?如果是怎么办???

【问题讨论】:

标签: c# asp.net url-rewriting seo


【解决方案1】:

您必须在 web 配置文件中进行配置

<rewrite>
        <rules>
            <rule name="RewriteASPX">
                <match url="(.*)" />
                <conditions logicalGrouping="MatchAll">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                </conditions>
                <action type="Rewrite" url="{R:1}.aspx" />
            </rule>
        </rules>
    </rewrite>

本文摘自以下链接

Remove HTML or ASPX Extension

【讨论】:

    猜你喜欢
    • 2012-05-12
    • 2013-03-14
    • 1970-01-01
    • 1970-01-01
    • 2020-11-08
    • 2023-04-05
    • 2020-08-06
    • 1970-01-01
    • 2017-02-24
    相关资源
    最近更新 更多