Redirect Sub-domain to Sub-directory (.Net Core)

Discussion in 'Site Programming, Development and Design' started by Graham Meehan, Jan 9, 2020.

  1. I've been trying to figure out for a while now if the following implementation is possible with WinHost and would be happy with any feedback.

    I have the following sub-domain:

    I have an application startpoint for a .Net Core 3.0 app on a shared Windows server at the following path from the domain root:


    I've modified the web.config in my domain's root directory as follows to be able to reach the application via the subdomain (

    <rule name="" stopProcessing="true">
    <match url=".*" />
    <add input="{HTTP_HOST}" pattern="^(www.)?" />
    <add input="{PATH_INFO}" pattern="^/myapp/" negate="true" />​
    <action type="Rewrite" url="\myapp\{R:0}" />

    While the application homepage loads fine initially with the proper url of, when I make any requests in my application the URL displays as follows:{app routing}

    Problem: How would I remove the "myapp/" subdirectory path from the URL on all requests?

    I figure the required change should be made in one of the following locations:
    1. Domain root web.config
    2. Startup.cs in MyApp using URL Rewriting Middleware
    3. XML file imported with URL Rewriting Middleware in Startup.cs of MyApp.
    I am having a ton of issues understanding the .NET Core URL Rewrite Middleware if that is what needs to be used in this case.
  2. Elshadriel

    Elshadriel Winhost Staff

    Try getting your .NET Core application working from the root first (i.e. routing works without it appending /myapp), then move it to the /myapp sub-directory. Then apply the URL Rewrite rules you mentioned above.

Share This Page