Laravel 5 – Remove Public from URL

后端 未结 30 2376
甜味超标
甜味超标 2020-11-22 03:20

I know this is a very popular question but I haven\'t been able to find a working solution for Laravel 5. I\'ve been trying to migrate from Codeigniter for a long time, but

30条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 03:48

    I would like to add to @Humble Learner and note that the proper location to "fix" the url path for assets is /Illuminate/Routing/UrlGenerator.php/asset().

    Update the method to match:

    public function asset($path, $secure = null)
    {
        if ($this->isValidUrl($path)) return $path;
        $root = $this->getRootUrl($this->getScheme($secure));
        return $this->removeIndex($root).'/public/'.trim($path, '/');
    }
    

    This will fix scripts, styles and image paths. Anything for asset paths.

提交回复
热议问题