【问题标题】:Laravel 5.5 Session::put() stores 'favicon.ico'Laravel 5.5 Session::put() 存储 'favicon.ico'
【发布时间】:2018-07-06 13:25:21
【问题描述】:

我有下一个代码:

    /*
    * If the route has someroute/en
    * where en is the lang of the page
    */
    $locale = $request->route('locale');
    if ( $locale != null ) {
        // 1. dd($locale)
        Session::put('_lang', $locale);
    } else {

        dd($request->session());
    }

所以当我运行没有 1. 注释的代码时,我得到了“en”。然后我删除了 dd($locale),然后运行 ​​Session:put()。因此,当我去某个路线或从路线中删除 /en 时,我得到的是“favicon.ico”而不是“en”。 有人知道为什么会这样吗?

额外:我在中间件上使用它,即在“网络”阵列上。我也使用文件作为我的会话存储。

【问题讨论】:

  • 这可能表明您的重写规则搞砸了,并将favicon.ico 捕获为框架请求而不是静态资源(或者您没有favicon.ico 文件)跨度>

标签: php laravel session middleware


【解决方案1】:

感谢@apokryfos

我的“公共”目录下没有 favicon.ico。

【讨论】:

    【解决方案2】:

    确保您将完整路径写入您的 favicon.ico 对于 Emx。

    <link href="http://www.example.com/favicon.ico" rel="shortcut icon">
    

    <link href="{{asset('/favicon.ico')}}" rel="shortcut icon">
    

    不仅仅是像 (href="favicon.ico") 这样的文件名

    还要确保您的“public”或“public_html”根目录中有此文件。

    Laravel 添加了一个空的 favicon.ico 文件 (0KB) 来避免这些问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-15
      • 1970-01-01
      • 2013-01-09
      • 1970-01-01
      相关资源
      最近更新 更多