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
from my experience so far, when you are done with coding your project
create a folder outside of public_html. you can call it maybe “project”
copy all your project files and upload to the project folder created.
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.
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);