简体   繁体   English

重定向到公共/在 php 工匠服务

[英]Redirect to public/ in php artisan serve

I have a laravel application that I made changes to the folder structure, I have been working with laragon and everything works fine but on my local environment and live server.我有一个 laravel 应用程序,我对文件夹结构进行了更改,我一直在使用 laragon 并且一切正常,但在我的本地环境和实时服务器上。

However, when i user php artisan serve, the generated url doesn't load assets in the public folder.但是,当我使用 php 工匠服务时,生成的 url 不会在公共文件夹中加载资产。

Eg例如

https://livewebsite.com // [live server] works.
https://myproject.local // [laragon] works.
http://localhost/myproject // [laragon /xampp] works
http://127.0.0.1:8000 // artisan [doesn't load assets, assets in the public directory returns 404
//e.g http://127.0.0.1:8000/public/assets/themes/cryptic/style/bgs.css  would return 404

Changes I made,我所做的改变,

|-core
|-public
|-.htaccess
|-index.php

I have moved all laravel core folders and files to the core folder, moved the .htaccess and index.php to the root directory.我已将所有 laravel 核心文件夹和文件移至核心文件夹,将 .htaccess 和 index.php 移至根目录。

From my debugging so far, I understand that laravel built in server redirects requests to the public folder where the index.php file is located.从我到目前为止的调试中,我了解到服务器内置的 laravel 将请求重定向到 index.php 文件所在的公用文件夹。

What changes can I make so that the request is not sent to the public folder, ie http://127.0.0.1:8000/public/assets/themes/cryptic/style/bgs.css should just be allowed to be without be redirected.我可以进行哪些更改以使请求不发送到公用文件夹,即http://127.0.0.1:8000/public/assets/themes/cryptic/style/bgs.css应该只允许不被重定向.

The entire thing works on various environments except when I'm using laravel built-in PHP server with the artisan command.整个过程适用于各种环境,除非我使用带有 artisan 命令的 laravel 内置 PHP 服务器。

I can't comment due to reputation, but what you're doing might be unsafe!由于声誉,我无法发表评论,但您所做的可能不安全!

This way all your project files will be public, which can expose credentials and exposes Composer packages to the public as well.这样,您的所有项目文件都将是公开的,这可以公开凭据并将 Composer 包也公开。 This means any PHP file in any Composer package can be executed, which can lead to remote code execution, which has happened before here and is described here .这意味着任何 Composer package 中的任何 PHP 文件都可以执行,这会导致远程代码执行,这在之前已经发生过,此处进行了描述。

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

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