You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

IIS重定向问题:含.axd路径请求返回500内部服务器错误

Fix IIS Rewrite Rule to Return 500 for .axd Paths

Hey there, let's sort out this IIS rewrite rule issue. You want requests containing .axd paths to return a 500 Internal Server Error, while all other sub-prefixed requests keep forwarding to your internal server as usual. Here's how to make that happen:

Step 1: Add a Priority Rule to Block .axd Requests

IIS processes rewrite rules top-to-bottom, so we need to add a rule that catches .axd requests first and stops further processing. This way, those requests never reach your internal server—they get the 500 response immediately.

Add this rule before your existing isite rewrite rule:

<rule name="Block AXD Requests with 500" enabled="true" stopProcessing="true">
    <!-- Matches any sub-prefixed URL ending with .axd -->
    <match url="^sub.*\.axd$" />
    <!-- Return a custom 500 response -->
    <action type="CustomResponse" 
            statusCode="500" 
            statusReason="Internal Server Error" 
            statusDescription="The server encountered an unexpected condition that prevented it from fulfilling the request." />
</rule>

Breakdown of key parts:

  • ^sub.*\.axd$: The regex targets URLs starting with sub and ending with .axd—this aligns with your existing rule's scope to avoid blocking unrelated .axd requests.
  • stopProcessing="true": Ensures once this rule matches, no subsequent rules (like your rewrite rule) run for that request.
  • CustomResponse: Tells IIS to send a 500 status code instead of rewriting the URL.

Step 2: Keep Your Existing Rewrite Rule

Leave your original rule in place, just make sure it comes after the new block rule:

<rule name="isite rewrite" enabled="true" stopProcessing="false">
    <match url="sub.*" />
    <action type="Rewrite" url="http://{MY_INTERNAL_SERVER}:8383/{R:0}"/>
</rule>

Step 3: Verify the Setup

  • Try accessing a .axd URL like http://sub.site.com/WebResource.axd?d=VulAtfIQPaLvaSxP9LTeiyvvAmd8FbIf6Q9ixGIp...—you should get a 500 error right away.
  • Test any other sub-prefixed URL (e.g., http://sub.site.com/your-page)—it should still forward to http://{MY_INTERNAL_SERVER}:8383/sub.your-page as expected.

内容的提问来源于stack exchange,提问作者Shay Hakshorian

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:46:35