zoukankan      html  css  js  c++  java
  • 在ionic这个框架下(Angular JS),对URL进行重写,过滤掉URL中的#号

    此时URL的改变已经完全不受后台代码控制了,因此我们要在前端的ionic这个框架和IIS中进行修改调控。

    其实IIS只是host了整个站点,具体的URL跳转都是由前端来控制的。

    1):那么前端要加上一行代码:

    $locationProvider.html5Mode(true);

    2):IIS对应的web.config要做如下处理,是每次经过IIS的请求都跳回主页,那么后续的URL管理都由前台框架来管理了:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <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="/" />
            </rule>
          </rules>
        </rewrite>
      </system.webServer>
    </configuration>

    3):要保证上述config能够生效,需要安装IIS URL Rewrite的插件,具体下载地址如下所示:

    http://www.iis.net/downloads/microsoft/url-rewrite 

    更多详细的信息请看如下链接:

    https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-configure-your-server-to-work-with-html5mode

  • 相关阅读:
    使用浏览器的 Local Storage 真的安全吗?
    传统到敏捷的转型中,谁更适合做Scrum Master?
    HBM2E Flashbolt--提升人工智能的算力
    C语言 for 循环
    C语言自加自减运算符(++i / i++)
    C语言逗号表达式
    C语言逻辑运算符
    C语言三目运算符
    C语言条件判断 if / else
    C语言 printf 函数
  • 原文地址:https://www.cnblogs.com/mingmingruyuedlut/p/4236049.html
Copyright © 2011-2022 走看看