I have hosted .net core web api as a website in iis, and added angular app as a application to the same website.
my application url is "http://example.com/angularapp" , now if users try using the url "http://example.com/" then I want them to get redirected to "http://example.com/angularapp". Note: My api urls are like this - "http://example.com/api/xyz" and I dont want that to be impacted. URL Rewrite rule that I tried in local environment
CodePudding user response:
If not already installed, add the URL Rewrite module to IIS using the download
Open this and click "Add Rule(s)..." and add a blank Inbound rule. You can configure rewrite rules here to automatically route requests around your site. In your case, the regex pattern ^http://example.com/$
would work, however you'd probably want to look at refining/expanding your rewrite rules to account for things such as automatically redirecting to HTTPS, forcing a trailing slash etc.
Set the action to rewrite and define the Rewrite URL as the location you want matched requests to point to, in this case
It will redirect http://example.com/
to http://example.com/angularapp
. BUT, if the url is http://example.com
, it won't redirect. I'm not sure if you want to redirect http://example.com
, so this just a remind.