laravel-8 - Laravel Project - After upload hosting server faced the issue for 500 Server Error and website menu link issue
问题描述
I have faced the issue for website not working properly.[Project file uploaded in sub folder]. Folder Path : example.com->public_html->lrvproject Please note the below issues:
- Home Page - 500 Server Error. https://www.example.com/lrvproject/
- Sub Pages open - I have manually enter page path it's showing page. Example: https://www.example.com/lrvproject/contact
- After loading subpages Menu link URL showing is "https://www.example.com/contact".
I have refer the tutorial inside public(folder copy all file and paste outside public folder).
index.php [https://www.example.com/lrvproject/index.php]
if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {
require __DIR__.'/../storage/framework/maintenance.php';
}
require __DIR__.'/../lrvproject/vendor/autoload.php';
$app = require_once __DIR__.'/../lrvproject/bootstrap/app.php';
$kernel = $app->make(Kernel::class);
$response = tap($kernel->handle(
$request = Request::capture()
))->send();
$kernel->terminate($request, $response);
web.php (routes)
use Illuminate\Support\Facades\Route;
//use App\Http\Controllers\UserAuthController;
Route::get('/','HomeController@index');
Route::get('/about', function () {
return view('pages/about');
});
Route::get('/gallery','ImageGalleryController@index');
Route::get('/contact','ContactController@index');
Route::post('/contact','ContactController@sendmail');
server.php [https://www.example.com/lrvproject/server.php]
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
return false;
}
require_once __DIR__.'/public/index.php';
//require_once __DIR__.'/index.php';
.htaccess [https://www.example.com/lrvproject/.htaccess]
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
# Disable Directory listing
Options -Indexes
# block files which needs to be hidden, specify .example extension of the file
<Files ~ "\.(env|json|config.js|md|gitignore|gitattributes|lock)$">
Order allow,deny
Deny from all
</Files>
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]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Already Server Folder Permission enabled. PHP extensions enabled. How to solve the issue. please help.
解决方案
我已经解决了这个问题。我已经更新了以下步骤。
.env 文件数据库详细信息已更新,现在我的主页可以正常工作了。
index.php [https://www.example.com/lrvproject/index.php] - 编辑
需要DIR .'/vendor/autoload.php'; $app = require_once DIR .'/bootstrap/app.php';
Web 菜单链接 URL-编辑
href="/lrvproject/contact" 链接路径更新“联系我们”
清除服务器缓存
我在服务器中运行的 Laravel 应用程序(子文件夹目录)
推荐阅读
- python - 使用 unicode 替换特殊字符
- arrays - 为什么每当我单独使用“if”语句以及在“if”中使用“if”时值会发生变化?
- c# - 关于在 Protobuf-net 中实现 VARIANT
- html - 嗨,我在 flexbox 中定位有问题
- reactjs - (React & Mobx & Leaflet)等待然后没有按我预期的那样工作
- javascript - 猫鼬填充返回未定义
- python - 在 Python 中使用 for 循环对多个 DataFrame 进行操作
- reactjs - 如何将 href 传递给 nextjs 中的 onClick 函数?
- python - 将字符串传递给 subprocess.run 似乎将其括在单引号中否定通配符搜索?
- c - 为什么 __builtin_return_address 在 Clang 中崩溃?