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

Windows Server环境下修改子域名并配置旧域名路径重定向咨询

How to Switch Subdomains and Configure WordPress Path Redirect on Windows Server

Hey there! Since you're not a Windows Server pro, let's walk through this clearly—no overly technical jargon where we can avoid it. Here's what you need to do:

DNS Setup (No Wildcard Needed!)

First, forget about wildcard DNS for this scenario. Wildcards are useful when you need all unknown subdomains (like random.ag.mydomain.com) to point somewhere, but you only have two specific subdomains to handle. Here's the step-by-step:

  • Add the new subdomain record: In your DNS manager, create an A record (or CNAME, if your original example.ag.mydomain.com uses a CNAME) for example1.ag.mydomain.com pointing to the same IP address as your existing Windows Server.
  • Keep the old subdomain record: Don't delete example.ag.mydomain.com yet—you need it to handle the redirect traffic. Leave its DNS record as-is for now.

Configure the Redirect in IIS

Assuming you're using IIS (the standard web server for Windows Server), you have two solid options to set up the /wordpress path redirect:

Option 1: Direct Redirect for the WordPress Directory

If wordpress is a physical directory or virtual directory under your example.ag.mydomain.com site:

  1. Open IIS Manager, navigate to your site for example.ag.mydomain.com.
  2. Find the wordpress directory, right-click it, and select Redirect.
  3. In the "Redirect to" field, enter https://example1.ag.mydomain.com/wordpress (use http if you don't have SSL set up).
    • If you want to redirect subpaths too (like /wordpress/post-123 to the same path on the new subdomain), check "Redirect all requests to exact destination" and change the target to https://example1.ag.mydomain.com/wordpress/$S$Q.
  4. Choose a redirect status code:
    • Use 301 (Permanent Redirect) if this change is long-term (good for SEO).
    • Use 302 (Temporary Redirect) if you might switch back later.
  5. Click Apply to save the settings.

Option 2: URL Rewrite Rule (More Flexible)

If you need finer control (or if you don't have a separate wordpress directory set up), use the IIS URL Rewrite module:

  1. First, make sure the URL Rewrite module is installed. If not, open IIS Manager > Web Platform Installer, search for "URL Rewrite", and install it.
  2. Go to your example.ag.mydomain.com site in IIS Manager, double-click URL Rewrite.
  3. Click Add Rule(s) > Select Blank Rule > OK.
  4. Configure the rule:
    • Name: Something descriptive like Redirect WordPress Path to New Subdomain
    • Match URL:
      • Pattern: ^wordpress(/.*)?$ (this matches /wordpress and any subpaths under it)
      • Ignore case: Checked
    • Conditions:
      • Click Add > Condition input: {HTTP_HOST} > Pattern: ^example\.ag\.mydomain\.com$ (this ensures the rule only applies to the old subdomain)
    • Action:
      • Action type: Redirect
      • Redirect URL: https://example1.ag.mydomain.com/wordpress{R:1} (the {R:1} captures the subpath from the original request)
      • Redirect type: Permanent (301) or Temporary (302)
  5. Click Apply to save.

Final Checks

  • Wait for DNS propagation: DNS changes can take anywhere from 5 minutes to a few hours to take effect globally. You can test with nslookup example1.ag.mydomain.com in Command Prompt to confirm it resolves to your server's IP.
  • Test the redirect: Open a browser and visit https://example.ag.mydomain.com/wordpress—it should automatically jump to the new subdomain's WordPress path. You can also use curl -I https://example.ag.mydomain.com/wordpress in Command Prompt to check the response headers (look for a 301/302 status and the correct Location header).

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.14 06:58:02