Laravel 5 – Remove Public from URL

后端 未结 30 2369
甜味超标
甜味超标 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:37

    Firstly you can use this steps

    For Laravel 5:

    1. Rename server.php in your Laravel root folder to index.php

    2. Copy the .htaccess file from /public directory to your Laravel root folder.

    source: https://stackoverflow.com/a/28735930

    after you follow these steps then you need to change all css and script path, but this will be tiring.

    Solution Proposal :simply you can make minor change the helpers::asset function.

    For this:

    1. open vendor\laravel\framework\src\Illuminate\Foundation\helpers.php

    2. goto line 130

    3. write "public/".$path instead of $path,

      function asset($path, $secure = null){
         return app('url')->asset("public/".$path, $secure);
      }
      

提交回复
热议问题