Laravel 5 – Remove Public from URL

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

    Just create .htaccess file at root and add these lines to it

    
        RewriteEngine On
    
        RewriteRule ^(.*)$ public/$1 [L]
    
    

    That's it!

    The above code works on the root public_html folder. Having said that your core laravel file should be inside the public_html folder, if your directory looks like public_html/laravelapp/public and if you put the above code inside laravelapp it won't work. Therefore you must copy all your core files into public_html and put the .htaccess file there .

    If you want to keep the code in a subdirectory then you can create a subdomain then this code will work for that also.

提交回复
热议问题