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

DotNetNuke URL重写求助:如何缩短指定Track访问URL

Fixing IIS URL Rewrite for Shortened Track URLs

Hey Chris, let's get that URL shortening working properly. The issue with your virtual directory approach is that it's just mapping a path to physical files, not rewriting the URL structure to hide the messy query string and aspx file. Here's how to fix this using IIS's URL Rewrite module—this is the standard way to handle clean URLs in IIS:

Step 1: Install the IIS URL Rewrite Module

First, make sure you have the URL Rewrite module installed on your IIS server. If you don't, open IIS Manager, go to your server node, and use the Web Platform Installer to search for and install "URL Rewrite".

Step 2: Remove the Existing "playtrack" Virtual Directory

The virtual directory you created will interfere with the rewrite rule (IIS will try to serve files from that directory first), so delete it from your main site before proceeding.

Step 3: Create a URL Rewrite Rule

Using IIS Manager GUI:

  1. Open IIS Manager and navigate to your main site.
  2. Double-click the URL Rewrite icon in the Features View.
  3. Click Add Rule(s) on the right-hand side.
  4. Choose Blank Rule under "Inbound Rules" and click OK.
  5. Configure the rule like this:
    • Name: Give it a descriptive name, like "Shorten Playtrack URL"
    • Pattern: Use this regular expression: ^playtrack/(\d+)$
      • This matches URLs like http://www.example.com/playtrack/18353, capturing the numeric track ID as a group.
    • Action Type: Select Rewrite (not Redirect—this keeps the clean URL in the address bar while serving the correct page)
    • Rewrite URL: Enter desktopmodules/imm/ims_cddetail/playtrack.aspx?trackid={R:1}
      • {R:1} refers to the first captured group (the track ID number) from the pattern.
    • Leave all other settings as default, then click Apply.

Alternatively, Edit web.config Manually

If you prefer editing the config file directly, add this section inside the <system.webServer> block of your site's web.config:

<rewrite>
  <rules>
    <rule name="Shorten Playtrack URL" stopProcessing="true">
      <match url="^playtrack/(\d+)$" />
      <action type="Rewrite" url="desktopmodules/imm/ims_cddetail/playtrack.aspx?trackid={R:1}" />
    </rule>
  </rules>
</rewrite>

Step 4: Test the Rule

Now try accessing http://www.example.com/playtrack/18353—it should load the content from the original long URL, but the address bar will stay clean with the shortened path.

Why this works: The rewrite rule intercepts the incoming request for the clean URL, translates it to the actual ASPX page with the track ID parameter, and serves that content without redirecting the user. This avoids the issues with virtual directories, which don't handle dynamic path-to-parameter mapping.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 07:31:35