To help with SEO and deep linking, I turned on html 5 mode in my angular project like this:
index.html
<base href="/webapplicationname/">
app.js
// use the HTML5 History API
$locationProvider.html5Mode(true);
web.config
<system.webServer>
<rewrite>
<rules>
<rule name="Main Rule" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/webapplicationname/" />
</rule>
</rules>
</rewrite>
</system.webServer>
My IIS Express debugging root is http://localhost:10223
and my local dev root is http://myvirtualmachine/webapplicationname
.
/webapplicationname/
does not exist in my debugging set up. Nor does it exist in the other environments past dev. But it has been handed down to me that any environment could be off the root or be in a web application folder with a name I don't control, so I can't count on or make a pattern.
I want to just use /
as my base
. If I did, it would work in debugging. I want to have that work in other environments regardless of where the web application lives relative to the web server root.
As it stands, If I change the root to /
, as in <action type="Rewrite" url="/" />
and <base href="/">
, /
points to the wrong place in my local dev environment. It would point to http://myvirtualmachine/
instead of http://myvirtualmachine/webapplicationname
, which will cause 404s. It needs to point to the root of my app, not the root of the web server!
How can I get ~/
-like functionality here?