首页 > 解决方案 > 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:

  1. Home Page - 500 Server Error. https://www.example.com/lrvproject/
  2. Sub Pages open - I have manually enter page path it's showing page. Example: https://www.example.com/lrvproject/contact
  3. 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.

标签: laravel-8laravel-routing

解决方案


我已经解决了这个问题。我已经更新了以下步骤。

  1. .env 文件数据库详细信息已更新,现在我的主页可以正常工作了。

  2. index.php [https://www.example.com/lrvproject/index.php] - 编辑

    需要DIR .'/vendor/autoload.php'; $app = require_once DIR .'/bootstrap/app.php';

  3. Web 菜单链接 URL-编辑

    href="/lrvproject/contact" 链接路径更新“联系我们”

  4. 清除服务器缓存

  5. 我在服务器中运行的 Laravel 应用程序(子文件夹目录)


推荐阅读