To develop websites on your local Windows 11 machine that is running IIS, you can follow these steps to bind a hostname to your website and add an entry in the Windows hosts file.
Step 1: Create a new website in IIS
-
Open IIS Manager by searching for it in the Start menu.
-
In the Connections pane, expand the Sites node.
-
Right-click on Sites, then select Add -> Website...
-
In the Add Website dialog box, enter the following information:
- Site Name: myTestSite
- Physical path: Select the folder where your website files are located
- TCP Port: 80 (for HTTP) or 443 (for HTTPS)
-
Click Next, then click Finish.
Step 2: Bind a hostname to your website
-
In the Connections pane, select your new website (myTestSite).
-
Double-click on the HTTP (or HTTPS) binding in the bindings section.
-
In the Edit Site Bindings dialog box, click Add...
-
In the Add Site Binding dialog box, enter the following information:
- Type: http (for HTTP) or https (for HTTPS)
- IP address: All Unassigned
- Port: 80 (for HTTP) or 443 (for HTTPS)
- Host name: Enter the hostname you want to use for your website (e.g., myTestSite.local)
-
Click OK, then click Close.
Step 3: Add an entry in the Windows hosts file
-
Open Notepad as an administrator by right-clicking on the Notepad shortcut, then selecting Run as administrator.
-
Click on File -> Open...
-
In the Open dialog box, navigate to
C:\Windows\System32\drivers\etc\and select the hosts file. -
In the hosts file, add the following line at the end:
127.0.0.1 myTestSite.localReplace
myTestSite.localwith the hostname you used in Step 2. -
Click File -> Save to save the changes.
Now, you should be able to access your website using the hostname you specified (e.g., http://myTestSite.local).
References