从公共目录复制.htaccess和index.php到根目录后,laravel资产文件未丢失

时间:2018-10-23 18:41:39

标签: php laravel css3

这是我的源代码,如下所示。我是laravel的新手,请解决此问题

<link href="http://localhost/eccomece/css/style.css" rel="stylesheet" type="text/css" media="all" />

1 个答案:

答案 0 :(得分:0)

您还必须更新asset()方法... 转到这个目录 C:\xampp\htdocs\detox\vendor\laravel\framework\src\Illuminate\Foundation\helper.php

并更新如下所示的asset()函数:

function asset($path, $secure = null)
    {
        if ($_SERVER['HTTP_HOST']=='127.0.0.1:8000')
            return app('url')->asset($path, $secure);
        if ($_SERVER['HTTP_HOST']=='localhost:8000')
            return app('url')->asset($path, $secure);
        else
            return app('url')->asset('public/'.$path, $secure);
    }