简体   繁体   English

更改 Laravel 8 上的公用文件夹

[英]Changing public folder on Laravel 8

I've just started (re)learning Laravel, now on this version 8, and working with a Apache Server (Xampp) that runs lots of other web applications (a server machine that run some essential internal services and APIs) and was thinking if it was possible to just put the public folder on the htdocs, so it's accessible, and the application outside of it.我刚刚开始(重新)学习 Laravel,现在在这个版本 8 上,并使用 Apache 服务器(Xampp)运行许多其他 web 的服务器(Xampp),如果服务器是运行一些基本的内部服务和 API 的机器)可以只将公用文件夹放在 htdocs 上,这样它就可以访问,而应用程序也可以放在它之外。

I've been using CodeIgniter 4.1.1 lately and was a tricky part to learn but now is rather simple to do, just changing one or two references inside the index.php code and it's done, how would it be done on Laravel 8?我最近一直在使用 CodeIgniter 4.1.1,这是一个很难学习的部分,但现在做起来相当简单,只需更改 index.php 代码中的一两个引用即可

If you want to bring public folder out of the project than you need to change the dir path inthe index.php file:如果您想将公用文件夹带出项目,则需要更改 index.php 文件中的 dir 路径:

from

   require __DIR__.'/../vendor/autoload.php';
   $app = require_once __DIR__.'/../bootstrap/app.php';

to

require __DIR__.'/vendor/autoload.php';
   $app = require_once __DIR__.'/bootstrap/app.php';

If you want to remove public from your app URL then you place your index.php and .htaccess to the root folder and The following change in index.php If you want to remove public from your app URL then you place your index.php and .htaccess to the root folder and The following change in index.php

from

  require __DIR__.'/../vendor/autoload.php';
  $app = require_once __DIR__.'/../bootstrap/app.php';

to

require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';

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

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