如何在本地Windows Server 2012的IIS 8.5服务器上配置子域名?
Got it, let's walk through setting up subdomains for your local IIS 8.5 server (SERVER_1) step by step. Since this is an internal setup, we’ll focus on the two critical pieces: configuring IIS to recognize the subdomain, and making sure your internal network knows where to send traffic for that subdomain.
- Launch IIS Manager on SERVER_1: Press
Win + R, typeinetmgr, and hit Enter. - In the left-hand Connections pane, find and select your existing MediaWiki site (the one that’s currently working with
http://SERVER_1). - Right-click the site and choose Edit Bindings... from the menu.
- In the Site Bindings window, click the Add... button.
- Fill out the binding form with these details:
- Type: Select
http(pickhttpsif you use internal SSL—just make sure you have a certificate set up). - IP address: Choose either your server’s specific internal IP (e.g.,
192.168.1.100) orAll Unassignedif you want the subdomain to respond on any IP the server uses. - Port: Keep
80(or your custom port if you’re not using the default). - Host name: Enter your desired subdomain, like
wiki.SERVER_1.localordocs.SERVER_1—use whatever naming convention makes sense for your internal setup.
- Type: Select
- Click OK to save the binding, then close the Site Bindings window.
Your internal computers need to know that the subdomain points to SERVER_1. Choose the option that fits your network size:
Option A: Local Hosts File (For Individual Test Machines)
If only a few PCs need access, edit the hosts file on each client:
- Open Notepad as Administrator on the client machine.
- Go to
File > Openand navigate toC:\Windows\System32\drivers\etc\hosts(you’ll need to select "All Files" from the file type dropdown to see it). - Add a line at the bottom like this:
Replace192.168.1.100 wiki.SERVER_1.local192.168.1.100with SERVER_1’s actual internal IP, andwiki.SERVER_1.localwith your chosen subdomain. - Save the file, then flush the client’s DNS cache by opening Command Prompt and running
ipconfig /flushdns.
Option B: Internal DNS Server (For Entire Network)
If you have a dedicated internal DNS server (like Windows Server DNS), add an A record to make the subdomain available to everyone:
- Open DNS Manager on your DNS server.
- Navigate to your internal domain zone (e.g.,
SERVER_1.localor your company’s internal domain). - Right-click the zone and select New Host (A or AAAA)....
- Fill in the details:
- Name: Enter just the subdomain part (e.g.,
wikiforwiki.SERVER_1.local). - IP address: Input SERVER_1’s internal IP.
- Check Create associated pointer (PTR) record if you want reverse DNS (optional, but useful for network troubleshooting).
- Name: Enter just the subdomain part (e.g.,
- Click Add Host to save the record.
- Grab an internal client machine, open your browser, and navigate to your subdomain URL (e.g.,
http://wiki.SERVER_1.local). It should load your MediaWiki site just like the originalhttp://SERVER_1URL. - If it doesn’t work, double-check these common issues:
- Did you enter the correct host name in the IIS binding?
- Is the DNS/hosts file entry pointing to the right IP?
- Is SERVER_1’s firewall allowing incoming traffic on port 80 (or your custom port)?
Quick Note
If you want the subdomain to point to a completely different site (not your existing MediaWiki), just create a new site in IIS, repeat Step 1 with the subdomain host name, and make sure the DNS record still points to SERVER_1.
内容的提问来源于stack exchange,提问作者test

