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

求助:Windows Server 2016下IIS 10特定图片路径301重定向配置

Hey there, let's get that 301 redirect sorted for you on IIS 10 running Windows Server 2016. Here are a couple of reliable methods to make this work perfectly:

  • First, make sure you have the URL Rewrite module installed. If you don't, open IIS Manager, go to "Web Platform Installer" (it's in the top-right menu), search for "URL Rewrite" and install it—it's a free official Microsoft module.
  • Open IIS Manager, navigate to your target website, then double-click the "URL Rewrite" icon.
  • On the right-hand pane, click "Add Rule(s)", select "Blank Rule", and configure these settings:
    • Name: Give it a descriptive name like "Image Path Permanent Redirect"
    • Pattern: Use this regex to match the old image path: ^folder1/folder2/folder3/folder4/([a-zA-Z0-9_]+_1\.jpg)$
      • The part in parentheses ([a-zA-Z0-9_]+_1\.jpg) captures the unique image filename (the xxxxx part), so it works for any matching image.
    • Conditions: You can leave this section empty—our pattern is specific enough to target only the images we want.
    • Action: Choose "Redirect", then:
      • Redirect Type: Select "Permanent (301)"
      • Redirect URL: Enter https://{HTTP_HOST}/folder6/folder7/folder8/folder9/folder10/{R:1}
      • {R:1} pulls in the filename we captured earlier, so each image maps directly to its new location.
    • Click "Apply" to save the rule, then test accessing an old image URL—you should be redirected to the new path instantly.
Method 2: Manually Edit the web.config File

If you prefer working directly with config files, edit (or create) the web.config file in your site's root directory and add this section:

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Image 301 Redirect" stopProcessing="true">
          <match url="^folder1/folder2/folder3/folder4/([a-zA-Z0-9_]+_1\.jpg)$" />
          <action type="Redirect" url="https://{HTTP_HOST}/folder6/folder7/folder8/folder9/folder10/{R:1}" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>
  • Save the file, and IIS will pick up the changes automatically. If it doesn't take effect right away, try refreshing your site in IIS Manager or restarting the IIS service.
Quick Notes
  • Ensure your site has a valid HTTPS certificate bound to it—since both the source and target URLs use HTTPS, this is a must.
  • Test using your browser's developer tools (F12 > Network tab) to confirm the response is a 301 status code.
  • If your xxxxx includes special characters like hyphens or periods, adjust the regex character set from [a-zA-Z0-9_] to something like [a-zA-Z0-9_-] to cover those cases.

内容的提问来源于stack exchange,提问作者Zohar Korenblum

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.06 10:52:29