角斜线得到EN codeD [英] Angular slash gets encoded

查看:132
本文介绍了角斜线得到EN codeD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

林有同样的问题,因为这家伙:

<一个href=\"http://stackoverflow.com/questions/17530924/angularjs-slash-after-hashbang-gets-en$c$cd\">angularjs-slash-after-hashbang-gets-en$c$cd

该URL获取EN codeD的它isn't正确路由,它似乎FAL的,否则在我的路由配置。
没有运气尚未找到原因,我的URL重写工作正常。 HTE唯一例外的是,当我在URL中的HTML5模式下添加hashbang一会儿。我预计将回退到hashbang和URL改写为HTML5模式。

任何人都知道这里发生了什么?

更新:
我会详细说明所提供的信息previously:

即时通讯使用Apache服务器端与在.htaccess以下配置:

 选项+的FollowSymLinks
IndexIgnore * / *
的DirectoryIndex index.htm的index.html的
&LT; IfModule mod_headers.c&GT;
    头中设置访问控制允许来源*
    头中设置访问控制,允许 - 头原产地,X-要求-着,内容类型,接受
&LT; / IfModule&GT;#HTML5 pushState的(历史)的支持: &LT; ifModule mod_rewrite.c&GT;
    RewriteEngine叙述上        #不要重写文件或目录
        的RewriteCond%{} REQUEST_FILENAME -f [OR]
        的RewriteCond%{} REQUEST_FILENAME -d
        重写规则^ - [L]        #重写一切来的index.html,让HTML5状态的链接
        重写规则^的index.html [L]
&LT; / ifModule&GT;

我的$ locationProvider和路由配置:

 的App.config(函数($ routeProvider,$ sceDelegateProvider,$ locationProvider){  $ locationProvider.html5Mode(真);
  $ locationProvider.hash preFIX(!);
  $ routeProvider.when('/ ROUTE1 /:参数',{
    templateUrl:/html/route1.html',
    控制器:'Route1Ctrl  });  $ routeProvider.when('/',{
    templateUrl:/html/route1.html',
    控制器:'Route1Ctrl
  });  $ routeProvider.when('/路径2',{
    templateUrl:/html/route2.html',
    控制器:'Route2Ctrl
  });   $ routeProvider.when('/路径3',{
    templateUrl:/html/route3.html',
    控制器:'Route3Ctrl
  });   $ routeProvider.when('/路径4',{
    templateUrl:/html/route4.html',
    控制器:'Route4Ctrl
  });   $ routeProvider.when('/ route5',{
    templateUrl:/html/route5.html',
    控制器:'Route5Ctrl
  });   $ routeProvider.when('/ route6',{
    redirectTo:'/路径4'
  });
  $ routeProvider.otherwise({
    redirectTo:/
  });
});


解决方案

我终于解决了它做两件事情:

1:我补充&LT;基本href =/&GT; 来的index.html结果
2:我激活HTML5模式,但没有preFIX

这样我可以使用的http://本地主机/#/路由的http://本地主机/路由和URL被正确重写。

Im having the same issue as this guy:

angularjs-slash-after-hashbang-gets-encoded

The URL gets encoded an it isn´t routed correctly, it appears to fal to the otherwise in my route config. No luck yet finding the reason, my URL rewriting is working fine. Hte only exception is when I add hashbang in the URL while in HTML5 mode. I expected to fallback to hashbang and rewrite the URL to html5 mode.

Anyone knows what is happening here?

Update: I will elaborate on the information provided previously:

Im using apache on the server side with the following config in .htaccess:

Options +FollowSymLinks
IndexIgnore */*
DirectoryIndex index.html index.htm
<IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
    Header set Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept"
</IfModule>



# html5 pushstate (history) support:

 <ifModule mod_rewrite.c>
    RewriteEngine on

        # Don't rewrite files or directories
        RewriteCond %{REQUEST_FILENAME} -f [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^ - [L]

        # Rewrite everything else to index.html to allow html5 state links
        RewriteRule ^ index.html [L]
</ifModule>

My $locationProvider and route config :

App.config(function($routeProvider, $sceDelegateProvider, $locationProvider) {

  $locationProvider.html5Mode(true);
  $locationProvider.hashPrefix('!');


  $routeProvider.when('/route1/:param', {
    templateUrl: '/html/route1.html',
    controller: 'Route1Ctrl'

  });

  $routeProvider.when('/', {
    templateUrl: '/html/route1.html',
    controller: 'Route1Ctrl'
  });

  $routeProvider.when('/route2', {
    templateUrl: '/html/route2.html',
    controller: 'Route2Ctrl'
  });

   $routeProvider.when('/route3', {
    templateUrl: '/html/route3.html',
    controller: 'Route3Ctrl'
  });

   $routeProvider.when('/route4', {
    templateUrl: '/html/route4.html',
    controller: 'Route4Ctrl'
  });

   $routeProvider.when('/route5', {
    templateUrl: '/html/route5.html',
    controller: 'Route5Ctrl'
  });

   $routeProvider.when('/route6', {
    redirectTo: '/route4'
  });


  $routeProvider.otherwise({
    redirectTo: "/"
  });


});

解决方案

I finally solved it doing two things:

1.- I added <base href="/"> to index.html
2.- I activated HTML5 mode but without prefix

This way I can use either http://localhost/#/route or http://localhost/route and the URL gets rewritten correctly.

这篇关于角斜线得到EN codeD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆