问题
I have a problem with my single page application made around Umbraco 7. I would like to redirect all requests to AngularJS instead of Umbraco, for that I have added the following urlrewrite to UrlRewriting.config:
<add name="SPA"
virtualUrl="^~/(?![0-9]+/)([^\?]*?)$"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/"
ignoreCase="true" />
But this redirects all responses to AngularJS, so now it not possible to open Umbraco at /umbraco. Does anyone know how to make a urlrewrite that redirects all responses to Angular except /umbraco?
回答1:
I've found that the solution was easier than it looked. Think regular expressions always is like that.The regular expression says: "From the start of the string after the base Url (~) exclude umbraco and ucommerce and uCommerce, the rest goes to base url.
Here's my solution:
<add name="Eventcatering"
virtualUrl="^~/(?!umbraco|ucommerce|uCommerce)(.*)"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/"
ignoreCase="true" />
I use the uCommerce package as well, which have some control API in /ucommerce, so these need to be excluded too.
来源:https://stackoverflow.com/questions/33688294/umbraco-7-single-page-application-routing