Our institution will only allow us one domain name (foo.bar.edu), so all of our websites are forced to be like this https://foo.bar.edu/Website1
I have a .NET Core 3.1 project, I am trying to get it to start on that site.
If I add this to the Configure, it will work, but also the default path will work.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UsePathBase("/Website1");
so now http://localhost:5000/Website1
works, but also http://localhost:5000
works too.
How can I disable http://localhost:5000
from working? Only paths that have /Website1
should work.
The real reason for this is to test production easily since production must be foo.bar.edu/Website1/route/Index
2
Answers
According to your description, if you want to disable the default path, I suggest you could consider using custom middleware.
You could build a custom middleware to disable all the path which is not start with the Website1.
More details, you could refer to below codes example:
Also you could consider using the asp.net core url rewrite middleware to redirect from / to /Website1.
More details about how to use url rewrite middleware, you could refer to this article.
Try something like below :