简体   繁体   English

如何配置 IIS URL 重写模块以在 url 上使用“HTML 5 pushState”样式和哈希片段?

[英]How to configure IIS URL Rewrite module to work with "HTML 5 pushState" style and hash fragments on url?

Angular 2 has a PathLocationStragy to work with html5 routes and a HashLocationStrategy to work with hash fragments '#' on routes. Angular 2 有一个PathLocationStratgy来处理 html5 路由,还有一个HashLocationStrategy来处理路由上的散列片段“#”。

The issue here is when we use OIDC (OpenID Connect) for user authentication and PathLocationStragy (or html5mode for routes on AngularJS) because OpenID on some flows returns data after a '#' fragment after redirect back to the site after user logging with a url as follow: http://mysite/callback#code=7b60c0570d7c4da0fc60678c0e46deadd5eeab0a659203fd44efb7cd51b2cdab&id_token=eyJhb ...这里的问题是当我们使用 OIDC(OpenID Connect)进行用户身份验证和PathLocationStragy (或html5mode用于 AngularJS 上的路由)时,因为某些流上的 OpenID 在用户使用 url 登录后重定向回站点后返回“#”片段后的数据如下: http://mysite/callback#code=7b60c0570d7c4da0fc60678c0e46deadd5eeab0a659203fd44efb7cd51b2cdab&id_token=eyJhb ...

For html5 routes is very common the settings bellow on IIS Url Rewrite:对于 html5 路由非常常见,IIS Url Rewrite 上的设置如下:

... <system.webServer> <rewrite> <rules> <remove name="AngularJS Routes" /> <rule name="AngularJS Routes" stopProcessing="true"> <match url=".*" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> <add input="{REQUEST_URI}" pattern="/(api)/" negate="true" /> </conditions> <action type="Rewrite" url="/" /> </rule> </rules> </rewrite> </system.webServer> ...

But when the web sever receives the url with http://mysite/callback#code=7b60c0570d7c4d from Authorization Server after user logging the response for this request is: 403 - Forbidden: Access is denied.但是,当用户记录此请求的响应后,Web 服务器从授权服务器接收到带有http://mysite/callback#code=7b60c0570d7c4d的 URL 时: 403 - Forbidden: Access is denied.

I think that the problem is with the Url rewrite settings, not with AngularJS or Angular 2 app´s... How to solve that?我认为问题在于 Url 重写设置,而不是 AngularJS 或 Angular 2 应用程序...如何解决? How to use AngularJS/Angular 2 with html5 route style and OpenID Connect?如何使用带有 html5 路由样式和 OpenID Connect 的 AngularJS/Angular 2?

Fragment values are not sent to the server, they are only handled client-side by the browser.片段值不会发送到服务器,它们仅由浏览器在客户端处理。 The browser is only sending http://mysite/callback浏览器只发送http://mysite/callback

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用angularJS的IIS URL重写模块不起作用 - IIS URL rewrite module with angularJS does not work 为AngularJS HTML5Mode配置IIS URL重写模块仍然不起作用 - Configure IIS URL Rewrite module for AngularJS HTML5Mode Still Not Working 在AngularJS中用Angular HTML5模式的节点重写IIS URL - IIS URL Rewrite in AngularJS with Node for Angular HTML5 Mode "如何配置 IIS 以在 HTML5 模式下重写 AngularJS 应用程序的 URL?" - How do I configure IIS for URL Rewriting an AngularJS application in HTML5 mode? Keycloak + AngularJS:登录重定向 url 后保留 URL 哈希片段 - Keycloak + AngularJS: persist URL hash fragments after login redirect url AngularJs $ locationProvider.html5Mode(true); 删除哈希到URL不起作用 - AngularJs $locationProvider.html5Mode(true); for remove Hash to URL not work 如何在Java上重写URL - How to rewrite url on java Angular.js-如何从URL中删除#-错误:无法在“历史记录”上执行“ pushState”: - Angularjs - How to remove the # from the url - Error: Failed to execute 'pushState' on 'History': 如何使用Angular pushstate URL抛出真实的404或301 - How do I throw a real 404 or 301 with an Angular pushstate URL 如何使用Google App Engine进行网址重写-HTML5模式不起作用 - How to url rewrite with Google app engine — HTML5 mode not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM