WordPress Domain Name in IIS

I am new to working with IIS and have set up two websites on it:

  • www.websiteA.com located at /directory1/websiteA
  • www.websiteB.com located at /directory1/websiteB

The websites have the same IP address but separate ‘A’ records. I bound them to their own URLs using the ‘Bindings’ option in IIS.

Website 1, www.websiteA.com is a simple HTML site and works as expected, masking the URL name.

Website 2, www.websiteB.com is a Wordpress installation. It works fine but does not mask the directory name in the URL bar.

I am using Windows Server 2019 and both websites have their own web.config files. HTTPS is not set up yet.

Do I need to create a URL rewrite or is there something else I can do to get www.websiteB.com to mask the directory name in the URL bar?

Yes, you need to create a URL rewrite rule to mask the directory name in the URL bar for www.websiteB.com. You can do this by adding the following lines inside the <system.webServer> tag in the web.config file of www.websiteB.com:

<rewrite>
  <rules>
    <rule name="Rewrite to directory1/websiteB">
      <match url=".*" />
      <action type="Rewrite" url="/directory1/websiteB/{R:0}" />
    </rule>
  </rules>
</rewrite>

This rule will rewrite all incoming URLs for www.websiteB.com to include the /directory1/websiteB/ prefix, which will mask the directory name in the URL bar. Make sure to replace {R:0} with {REQUEST_URI} if you’re using IIS 8.0 or later.