Avoid public folder of laravel and open directly the root in web server

前端 未结 9 2110
礼貌的吻别
礼貌的吻别 2020-11-29 16:45

I was going through all possible sample on internet to solve this. Still it is an headache.

I just want to avoid the \'public\' in www.mylaravelsite.com/public

9条回答
  •  离开以前
    2020-11-29 17:37

    For Lumen

    Let's think you have a folder path like: /var/www/project/microservice(lumen src)

    /var/www => document root for localhost/

    Target you want: localhost/project/microservice[/foo...] => localhost/project/microservice/public/foo...

    I do this by .htaccess (placed at /project folder) like below:

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !^.*/public/.*
    RewriteCond %{REQUEST_URI} ^(/[^/]+/[^/]+/).*
    RewriteRule ^[^/]+(.*)$ %1public$1 [L,R=301,P]
    

提交回复
热议问题