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

前端 未结 9 2113
礼貌的吻别
礼貌的吻别 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:24

    create .htacess file in the root directory of your laravel project and put this code in.

    
    
        Options -MultiViews
    
    
    RewriteEngine On
    
    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^ ^$1 [N]
    
    RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
    RewriteRule ^(.*)$ public/$1 
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ server.php
    

提交回复
热议问题