skip to Main Content

I have problem upload Laravel to hosting cpanel,after that i try to open "mydomain.com/mahasiswa" just Blank Page

this my structure Folder
enter image description here

this myfolder in the directory public_html
enter image description here

this myfolder in the first directory
enter image description here

this is my code index.php in folder public

<?php

use IlluminateContractsHttpKernel;
use IlluminateHttpRequest;

define('LARAVEL_START', microtime(true));


if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
    require $maintenance;
}

require __DIR__.'/../mahasiswa/vendor/autoload.php';

$app = require_once __DIR__.'/../mahasiswa/bootstrap/app.php';

// set the public path to this directory
$app->bind('path.public', function() {
return __DIR__;
});

$kernel = $app->make(Kernel::class);

$response = $kernel->handle(
    $request = Request::capture()
)->send();

$kernel->terminate($request, $response);

i try to change position directory public item to mahasiswa first directory and i the another folder same like that to i changed but it can’t solved

i wish the process deploy is successfully and not the blank page

2

Answers


  1. Follow below steps to upload Laravel project on shred hosting only.

    First of all you don’t need to alter directory structure of your project, just keep the original folder structure provided by the Laravel.

    • and then upload whole project on the server as it is.
    • then copy your .htaccess file from public folder and paste it outside(root directory of your project) and edit this newly copied .htaccess file by adding below lines in it.
        RewriteEngine On
        RewriteCond %{HTTP_HOST} ^yourdomain.com$ [NC,OR]
        RewriteCond %{HTTP_HOST} ^www.yourdomain.com$
        RewriteCond %{REQUEST_URI} !public/
        RewriteRule (.*) /public/$1 [L]
    
    

    instead of yourdomain.com put your original domain name.

    after this your complete .htaccess should look like this.

    <IfModule mod_rewrite.c>
        <IfModule mod_negotiation.c>
            Options -MultiViews -Indexes
        </IfModule>
    
        RewriteEngine On
        RewriteCond %{HTTP_HOST} ^yourdomain.com$ [NC,OR]
        RewriteCond %{HTTP_HOST} ^www.yourdomain.com$
        RewriteCond %{REQUEST_URI} !public/
        RewriteRule (.*) /public/$1 [L]
    
        # 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>
    

    Also check the php version of your server and your project

    Login or Signup to reply.
  2. Laravel application deployment on a Sub-domain is easier than sub-directory with cPanel Hosting

    Just create a sub-domain and document root like subdomain.yourdomain.com/public

    Upload all files of the Laravel application after successful upload just delete everything inside the bootstrap/cache folder

    I hope this is helpful for you.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search