0

I need help getting a subdomain to work in my domain. Here's what I've done:

  1. Using an FTP program, I created two subfolders in my root folder: WebApp1 and WebApp2

  2. From the my web host's Control Panel, I created two Subdomain Pointers: WebApp1.MyDomain.Com pointing to subfolder WebApp1 and WebApp2.MyDomain.Com pointing to subfolder WebApp2

  3. Using VS2019Pro I created an ASP.NET Core 3.0 Web Application (not MVC), called WebApp1, and successfully used Web Deploy to upload it to the WebApp1 subfolder.

  4. Using a text editor and FTP program I created a simple index.html page and put it in the WebApp2 subfolder.

  5. In the root of mydomain.com I made a Web.Config file that looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>

<rule name="webapp1.mydomain.com">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^webapp1.mydomain.com$" />
<add input="{PATH_INFO}" pattern="^/webapp1/" negate="true" />
</conditions>
<action type="Rewrite" url="\webapp1\{R:0}" />
</rule>

<rule name="webapp2.mydomain.com">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^webapp2.mydomain.com$" />
<add input="{PATH_INFO}" pattern="^/webapp2/" negate="true" />
</conditions>
<action type="Rewrite" url="\webapp1\{R:0}" />
</rule>

</rules>
</rewrite>
</system.webServer>
</configuration>​

The result:

  • Going to h t t p://WebApp1.mydomain.com, (ASP.Net project) I get a totally blank screen. No webpage. No error. However, when I go to h t t p://www.mydomain.com/webapp1 it works totally fine. I see the ASP.Net Core App that I wrote and it works exactly as I want it to.

  • Meanwhile, going to h t t p://WebApp2.mydomain.com, (text editor project) it works flawlessly. So, I know the web.config file is working for a very simple target website, but it's NOT workign when I redirect to the far more complex ASP.Net web application at WebApp1.

What am I doing wrong? How do I tell my ASP.Net Core 3.0 project in the WebApp1 folder to properly route the incoming requests?

Thank you for any help and/or suggestions!

Jason

SqueezeOJ
  • 441
  • 7
  • 17
  • I haven't done this for a while, but there are a few things I see. 1. Your `webapp2.mydomain.com` rule is actually rewriting to `\webapp1`. 2. I can't remember if the `\\``s in the rewrite actions actually need to be `/`, although it may not matter. 3. I think you should read [this answer](https://stackoverflow.com/questions/16998832/iis-url-rewrite-rn-clarification) as I think `R:0` may not be what you want. – John H Apr 06 '20 at 16:58
  • Thank you, John. I will check this out! – SqueezeOJ Apr 07 '20 at 15:43

0 Answers0