I’m trying to deploy a laravel version 11 but I got HTTP ERROR 500, I used FileZilla to transfer files because cPanel doesn’t has SSH.
I followed some tutorials and moved the .htaccess, index.php from public directory to the public_html directory and changed the paths from ./../ to ./
and when I try to access a route like login it sends a forbidden error.
Index.php
<?php
use IlluminateHttpRequest;
define('LARAVEL_START', microtime(true));
// Determine if the application is in maintenance mode...
if (file_exists($maintenance = __DIR__.'/storage/framework/maintenance.php')) {
require $maintenance;
}
// Register the Composer autoloader...
require __DIR__.'/vendor/autoload.php';
// Bootstrap Laravel and handle the request...
(require_once __DIR__.'/bootstrap/app.php')
->handle(Request::capture());
.htaccess
<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]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php82” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php82 .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
bootstap.app
In the cPanel I found a marked error x “syntax error” on the line of the return, I copied the code and put it on VS code and doesnot trigger any error ! so I don’t know is this is the issue or not !!
<?php
use IlluminateFoundationApplication;
use IlluminateFoundationConfigurationExceptions;
use IlluminateFoundationConfigurationMiddleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
api: __DIR__.'/../routes/api.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware) {
$middleware->web(append: [
IlluminateCookieMiddlewareEncryptCookies::class,
IlluminateCookieMiddlewareAddQueuedCookiesToResponse::class,
IlluminateSessionMiddlewareStartSession::class,
IlluminateViewMiddlewareShareErrorsFromSession::class,
IlluminateFoundationHttpMiddlewareValidateCsrfToken::class,
IlluminateRoutingMiddlewareSubstituteBindings::class,
IlluminateSessionMiddlewareAuthenticateSession::class,
AppHttpMiddlewareSetLocale::class,
]);
I moved the .htaccess, index.php from public directory to the public_html directory and changed the paths from ./../ to ./
I checked the log files and it doesnot type any new errors. I searched for errors in log and storage and I didnot find any new errors and tried using try and catch and it didnot return errors !!