Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/366.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AngularJS html5mode=使用参数直接访问url时出现true错误_Javascript_Php_.htaccess_Angularjs_Symfony - Fatal编程技术网

Javascript AngularJS html5mode=使用参数直接访问url时出现true错误

Javascript AngularJS html5mode=使用参数直接访问url时出现true错误,javascript,php,.htaccess,angularjs,symfony,Javascript,Php,.htaccess,Angularjs,Symfony,我用Angularjs和Symfony 2开发了一个应用程序,我启用了html5模式来获得友好的URL 该应用程序与Symfony 2.3集成,以在服务中响应 app.js .config(['$routeProvider', '$locationProvider','$provide' , function($routeProvider, $locationProvider,$provide) { $provide.decorator('$sniffer', function(

我用Angularjs和Symfony 2开发了一个应用程序,我启用了html5模式来获得友好的URL

该应用程序与Symfony 2.3集成,以在服务中响应

app.js

 .config(['$routeProvider', '$locationProvider','$provide' , function($routeProvider, $locationProvider,$provide) {

      $provide.decorator('$sniffer', function($delegate) {
            $delegate.history = false;
            return $delegate;
        });

    $routeProvider.when('/home', {templateUrl: 'views/home.html', controller: 'HomeController'});
    $routeProvider.when('/quienes_somos', {templateUrl: 'views/quienes_somos.html', controller: 'QuienesSomosController'});
    $routeProvider.when('/ubicanos', {templateUrl: 'views/ubicanos.html', controller: 'UbicanosController'});
    $routeProvider.when('/ubicanos/:route', {templateUrl: 'views/ubicanos.html', controller: 'UbicanosController'});
    $routeProvider.when('/catalogo', {templateUrl: 'views/catalogo.html', controller: 'CatalogoController' });
    $routeProvider.when('/catalogo/:category', {templateUrl: 'views/catalogo.html', controller: 'CatalogoController' });
    $routeProvider.when('/catalogo/:category/:productid', {templateUrl: 'views/catalogo.html', controller: 'CatalogoController'});
    $routeProvider.when('/catalogo/results',{templateUrl: 'views/catalogo.html', controller: 'CatalogoController'});
    $routeProvider.when('/noticias', {templateUrl: 'views/noticias.html', controller: 'NoticiasController'});

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

        $locationProvider.html5Mode(true);
  }]);
当我试图直接访问某个类别的路由和参数时,就会出现问题

Angularjs不加载。但是其他的路线是正确的

非工作路线

我还在index.html

这是.htaccess

DirectoryIndex app.php

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
    RewriteRule ^(.*) - [E=BASE:%1]
    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]

    # If the requested filename exists, simply serve it.
    # We only want to let Apache serve files and not directories.
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule .? - [L]

    # Rewrite all other queries to the front controller.
    RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>

<IfModule !mod_rewrite.c>
    <IfModule mod_alias.c>
        RedirectMatch 302 ^/$ /app.php/
    </IfModule>
</IfModule>
DirectoryIndex app.php
重新启动发动机
RewriteCond%{REQUEST_URI}:$1^(/.+)/(.*):\2$
重写规则^(.*)-[E=基:%1]
RewriteCond%{ENV:REDIRECT_STATUS}^$
重写规则^app\.php(/(.*)|$)%{ENV:BASE}/$2[R=301,L]
#如果请求的文件名存在,只需提供它即可。
#我们只想让Apache服务于文件,而不是目录。
RewriteCond%{REQUEST_FILENAME}-f
重写规则[L]
#将所有其他查询重写到前端控制器。
重写规则.?%{ENV:BASE}/app.php[L]
重定向匹配302^/$/app.php/
我已经对htaccess进行了修改以使其正常工作,但并不幸运。它向后滚动

有什么想法吗?请
谢谢。

您已将html5mode设置为true,但您提到的示例URL看起来像是在使用hashbang。这只是打字错误吗

http://plastimex.localhost/index.html#/catalogo/tablilla-plastica
应该是

http://plastimex.localhost/catalogo/tablilla-plastica
对不起,我会留下这个作为评论,但我没有要点


链接到相关文档:

您已将html5mode设置为true,但您提到的示例URL看起来像是在使用hashbang。这只是打字错误吗

http://plastimex.localhost/index.html#/catalogo/tablilla-plastica
应该是

http://plastimex.localhost/catalogo/tablilla-plastica
对不起,我会留下这个作为评论,但我没有要点


链接到相关文档:

你好,马特,没关系,我也用过,但运气不好。我使用它,它工作正常。我不知道我用params时有什么问题。你好,Matt,没关系,我也用过,但不走运。我使用它,它工作正常。我不知道我使用params时出现了什么问题。我最近遇到了一个带有参数的路由不工作的问题。当我将其从/foo/:id更改为/foo/:id/bar时,它开始工作–不知道为什么:)Hello@aweibell上周,当我将所有index.html内容更改为Symfony视图时,问题得到了解决。twig,出现了路由冲突,Htaccess无法工作。现在它开始工作了。谢谢我最近遇到了一个参数不起作用的路由问题。当我将其从/foo/:id更改为/foo/:id/bar时,它开始工作–不知道为什么:)Hello@aweibell上周,当我将所有index.html内容更改为Symfony视图时,问题得到了解决。twig,出现了路由冲突,Htaccess无法工作。现在它开始工作了。非常感谢。