简体   繁体   English

使用根索引文件访问laravel公用文件夹

[英]Accesing laravel public folder using root index file

Laravel Version - 5.8. Laravel版本-5.8。

I have to deploy my Laravel project on Shared Hosting without using php artisan serve command. 我必须在不使用php artisan serve命令的情况下在共享主机上部署Laravel项目。 So for that reason, I have renamed my root file server.php file to index.php . 因此,由于这个原因,我将我的根文件server.php文件重命名为index.php

Will there be any security consequences or bug, if I rename the file server.php to index.php ? 如果我将server.php文件重命名为index.php ,会不会有任何安全后果或错误?

you don't need to rename server.php to index.php. 您无需将server.php重命名为index.php。 Just move the Public/index.php to the root of the folder and change the necessary path inside the index.php after moving. 只需将Public / index.php移动到文件夹的根目录,然后在移动后更改index.php内部的必要路径。 It will work for sure. 它肯定会工作。

If you using cPanel, you can change webroot to public very simple don't need to rename server.php . 如果使用cPanel,则可以非常简单地将webroot更改为public ,而无需重命名server.php If not you can using .htaccess to redirect all request to public folder like this : 如果没有,你可以用.htaccess重定向所有请求public这样的文件夹:

# public_html/.htaccess

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect All Requests To The Subfolder
    RewriteRule ^ /public

</IfModule>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM