Php 带Yii 2的角度JS,从url隐藏

Php 带Yii 2的角度JS,从url隐藏,php,angularjs,yii,Php,Angularjs,Yii,我已经开始了一个项目,前端是angular Js,后端是Yi2框架。一切都很正常,除了网站url每次都包含一个#/,而且是注释。我想把它藏起来。我尝试了以下方法: if(window.history && window.history.pushState){ //$locationProvider.html5Mode(true); will cause an error $location in HTML5 mode requires a tag

我已经开始了一个项目,前端是angular Js,后端是Yi2框架。一切都很正常,除了网站url每次都包含一个#/,而且是注释。我想把它藏起来。我尝试了以下方法:

        if(window.history && window.history.pushState){
        //$locationProvider.html5Mode(true); will cause an error $location in HTML5 mode requires a  tag to be present! Unless you set baseUrl tag after head tag like so: <head> <base href="/">

        // to know more about setting base URL visit: https://docs.angularjs.org/error/$location/nobase

        // if you don't wish to set base URL then use this
        $locationProvider.html5Mode({
            enabled: true,
            requireBase: false
        });
    }
Next exception
'yii\web\NotFoundHttpException'和消息“Page not found.”在C:\xampp\htdocs\angularyii\vendor\yiisoft\yii2\web\Application.php:95中
堆栈跟踪:

#0 C:\xampp\htdocs\angularyii\vendor\yiisoft\yii2\base\Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#1 C:\xampp\htdocs\angularyii\frontend\web\index.php(18): yii\base\Application->run()
#2 {main}

我怎样才能解决这个问题?非常感谢。

服务器端应该为每个请求发送index.html。您的确切意思是什么@你的网站/工作对吗?因为服务器发送index.html或运行index.php,所以对站点/资产内的每个路由都执行相同的操作。可能是重写规则。htaccess中的index.php-看看这个实现-
#0 C:\xampp\htdocs\angularyii\vendor\yiisoft\yii2\base\Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#1 C:\xampp\htdocs\angularyii\frontend\web\index.php(18): yii\base\Application->run()
#2 {main}