I am using Angular 7 alongside with IIS server. I would like to enable deep linking without enabling hash location strategy
(RouterModule.forRoot(routes, {useHash: true}))
My app path consists of a domain and a subdomain:
http://www.example.com/mysubdomain/
index.html:
<base href="/mysubdomain/" />
I have added also into Web.config file of Visual Studio the following rewrite rule:
<rewrite>
<rules>
<rule name="RedirectRule" stopProcessing="true">
<match url="contacts" />
<action type="Rewrite" url="/mysubdomain/" appendQueryString="false" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
"contacts" is a routing path declared in my routing module. The above configuration works if I type ' http://www.example.com/mysubdomain/contacts ' in the browswer and hit enter, but it fails (404.0 - Not Found) when I replace "contacts" with anything else. I have tried to replace the value of url attribute with ".*" but it doesn't work either.
Since your app path is : http://www.example.com/mysubdomain/
just set following changes for the base url after building your project.
// in index.html
<base href="./" />
//The base tag tells our Angular application where it will be deployed. I had similiar issue and this has fixed for me.Let me know if any issues!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.