问题描述
提前感谢您的帮助。 我是 Laravel 的新手,我正在做这个项目并同时学习 Laravel。正如我在标题中所写的那样,当它在 Cpanel 上时,项目和文件在实时托管上加载良好。但是,当我下载它时,文件不起作用。我找到了解决方案,但效果不佳。路径不起作用。我的解决方案是遍历每个文件并更改路径,但这需要时间。
它在 cpanel 上工作的原因是因为 .htaccess 文件吗? .htaccess的代码在这里-
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.PHP [L]
</IfModule>
# BEGIN cPanel-generated PHP ini directives,do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file,use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information,read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule PHP7_module>
PHP_flag display_errors Off
PHP_value max_execution_time 60
PHP_value max_input_time 120
PHP_value max_input_vars 3000
PHP_value memory_limit 256M
PHP_value post_max_size 16M
PHP_value session.gc_maxlifetime 1440
PHP_value session.save_path "/var/cpanel/PHP/sessions/ea-PHP74"
PHP_value upload_max_filesize 20M
PHP_flag zlib.output_compression Off
</IfModule>
<IfModule lsapi_module>
PHP_flag display_errors Off
PHP_value max_execution_time 60
PHP_value max_input_time 120
PHP_value max_input_vars 3000
PHP_value memory_limit 256M
PHP_value post_max_size 16M
PHP_value session.gc_maxlifetime 1440
PHP_value session.save_path "/var/cpanel/PHP/sessions/ea-PHP74"
PHP_value upload_max_filesize 20M
PHP_flag zlib.output_compression Off
</IfModule>
# END cPanel-generated PHP ini directives,do not edit
我给出了 index.PHP
和 server.PHP
的代码。如果您需要完整的 zip 文件,可以在评论中告知。
Index.PHP-
<?PHP
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com>
*/
define('LaraVEL_START',microtime(true));
/*
|--------------------------------------------------------------------------
| Register The AutoLoader
|--------------------------------------------------------------------------
|
| Composer provides a convenient,automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/
require __DIR__.'/vendor/autoload.PHP';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development,so let us turn on the lights.
| This bootstraps the framework and gets it ready for use,then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/bootstrap/app.PHP';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application,we can handle the incoming request
| through the kernel,and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request,$response);
enter code here
Server.PHP-
<?PHP
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com>
*/
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'],PHP_URL_PATH)
);
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
return false;
}
require_once __DIR__.'/public/index.PHP';
我从 index.PHP 中的“/public/index.PHP”中删除了“/public”,因为它不在公共文件夹中。这奏效了,但随后每个文件上的所有其他路径都搞砸了。
根目录和公用文件夹-
我可以再一次更改路径,但有 2 个供应商文件夹,有时也会令人困惑。如果没有更好的解决方案,请告诉我改变每条路径的更快方法。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)