skip to Main Content

How to upload larval project on cpanel using only.Htaccess file. I saw already more of the example, but not worked properly. This is throwing the error is This page isn’t working. I put my project inside http://www.domainname.com/laravelproject. Inside this we change the index.php file in the public folder.

file is this-

<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>

public/index.php

require __DIR__.'/../filename/vendor/autoload.php';
$app = require_once __DIR__.'/../filename/bootstrap/app.php';

2

Answers


  1. from my experience so far, when you are done with coding your project

    1. create a folder outside of public_html. you can call it maybe “project”

    2. copy all your project files and upload to the project folder created.

    3. open the public folder in your laravel project and copy all the files including the .htaccess and index.php files to the public_html folder.

    4. then open index.php files and change the following pointing to the project folder you created.

      define(‘LARAVEL_START’, microtime(true));

      require DIR.’/../project/vendor/autoload.php’;

      $app = require_once DIR.’/../project/bootstrap/app.php’;

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

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

      $response->send();

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

    Login or Signup to reply.
  2. in your case, http://www.domainname.com/laravelproject   
    
    1. create a folder name "project"  outside of the public_html and place all the laravel files inside it. 
    
    2. also create a folder name laravelproject inside public_html/laravelproject. 
    
    3. then open the laravel public folder inside "project" folder and copy all the files to the public_html/laravelproject. 
    
    4. open index.php inside public_html/laravelproject and change the  
    
      require DIR.'/../../project/vendor/autoload.php';
      $app = require_once DIR.'/../../project/bootstrap/app.php';
    
      or
    
      require DIR.'/../project/vendor/autoload.php';
      $app = require_once DIR.'/../project/bootstrap/app.php';
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search