Windows 2019
Sponsored Link

IIS : Configure Virtual Directory2019/08/29

 
Configure Virtual Directory.
It's possible to set specific physical folder as a specific URL Path.
[1] Run PowerShell with Admin Privilege and Configure.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Users\Administrator> Get-Website -Name "Default Web Site" 

Name             ID   State      Physical Path                  Bindings
----             --   -----      -------------                  --------
Default Web Site 1    Started    %SystemDrive%\inetpub\wwwroot  http *:80:

# for example, set physical folder [C:\inetpub\wwwroot\virtual_dir], URL Path [/vDir] on [Default Web Site]
PS C:\Users\Administrator> mkdir C:\inetpub\wwwroot\virtual_dir 
PS C:\Users\Administrator> New-WebVirtualDirectory -Site "Default Web Site" -Name "vDir" -PhysicalPath "C:\inetpub\wwwroot\virtual_dir" 

Name PhysicalPath
---- ------------
vDir C:\inetpub\wwwroot\virtual_dir

PS C:\Users\Administrator> Get-WebVirtualDirectory -Site "Default Web Site" 

Name             Physical Path
----             -------------
vDir             C:\inetpub\wwwroot\virtual_dir

# create a test page
PS C:\Users\Administrator> Write-Output "IIS Virtual Directory Test Page" | Out-File C:\inetpub\wwwroot\virtual_dir\index.html -Encoding Default 

# verify accesses
PS C:\Users\Administrator> curl.exe localhost/vDir/ 
IIS Virtual Directory Test Page
IIS : Configure Virtual Directory (GUI)
 
On GUI configuration, set like follows.
[2] Run [Start] - [Server Manager] and Click [Tools] - [Internet Information Services (IIS) Manager], and then Click [View Virtual Directories] on the right pane.
[3] Right Click on any place on the center pane and open [Add Virtual Directory].
[4] Input URL Path for [Alias] field, for [Physical Path] field, input Physical folder Path.
[5] After added normally, new virtual directory is listed.
[6] Create a test page under the directory you set as Physical Path for virtual directory setting, and verify accesses.
Matched Content