[英]Laravel: Put index.php in a subfolder of public folder
I have singlepage app at https://example.com . 我在https://example.com上有单页应用程序。 App's api and backend is driven by laravel.
应用程序的api和后端由laravel驱动。 Can someone point me to the right direction how to open my spa at: https://example.com and backend at https://example.com/backend
有人可以为我指出正确的方向如何在以下位置打开我的水疗中心: https : //example.com和后端在https://example.com/backend
What I've tried: 我尝试过的
I've put all my files of SPA in public folder and move laravel public files (including .htaccess and index.php) in public/backend folder 我已将SPA的所有文件都放在公用文件夹中,并将laravel公用文件(包括.htaccess和index.php)移动到了公用/后端文件夹中
Changed the public path of laravel to public/backend 将laravel的公共路径更改为公共/后端
This gives me Internal Server Error when access https://example.com/backend 这会在访问https://example.com/backend时给我内部服务器错误
Thanks in advance! 提前致谢!
Edit your routing so the api
group is changed to backend
. 编辑您的路由,以便将
api
组更改为backend
。 Then create a route in the web
group for /
which loads a blade template containing your vue components and vue router. 然后在
web
组中为/
创建一个路由,以加载包含vue组件和vue路由器的刀片模板。 The vue router will handle the SPA page loads after its loaded. vue路由器在加载SPA页面后将对其进行处理。
In this case you'll have an entry point for your backend which is index.php
. 在这种情况下,您将为后端提供一个入口点,即
index.php
。 And you'll have an entry point for your SPA which will be index.html
. 而且,您的SPA的入口将是
index.html
。 I would advice you to keep your index.php
in the /public
folder of our Laravel installation. 我建议您将
index.php
保留在Laravel安装目录的/public
文件夹中。 Then change the way index.html
is compiled so it's placed in a different folder, lets say /build
. 然后更改
index.html
的编译方式,将其放置在另一个文件夹中,比如说/build
。 You can probably achieve this by adjusting some webpack or vue-cli settings. 您可能可以通过调整一些webpack或vue-cli设置来实现。 Then adjust your webserver configuration (apache/nginx) so it will have the following two entries:
然后调整您的Web服务器配置(apache / nginx),使其具有以下两个条目:
/var/www/{project}/public
/var/www/{project}/public
https://example.com/backend /var/www/{project}/build
/var/www/{project}/build
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.