Ahmed Laggoun
Ahmed Laggoun

Reputation: 191

Error serving routes of subdomain on cpanel Laravel 11

I developed Laravel 11 website. I have subdomain for admin panel this is my routes/web.php file:

Route::domain('admin.domain')->name('admin.')->group( function () {

            Route::get('/', 'index')->name('login.index');
            Route::get('/login', 'index')->name('login.show');
});

On my localhost all works fine, but when I uploaded my project to cpanel and entering / it shows the login page as expected but /login returns 404 not found error of server not 404 of laravel. this is how I uploaded my website to cpanel:

  1. created subdomain on cpanel and pointed it to the document root (public_html).
  2. created web_files folder then uploaded all site files to it except public files.
  3. Uploaded public files to document root (public_html).
  4. I edited index.php file like this:
<?php

use Illuminate\Http\Request;

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')
    ->handleRequest(Request::capture());


to

<?php

use Illuminate\Http\Request;

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

// Determine if the application is in maintenance mode...
if (file_exists($maintenance = __DIR__.'/../web_files/storage/framework/maintenance.php')) {
    require $maintenance;
}

// Register the Composer autoloader...
require __DIR__.'/../web_files/vendor/autoload.php';

// Bootstrap Laravel and handle the request...
(require_once __DIR__.'/../web_files/bootstrap/app.php')
    ->handleRequest(Request::capture());


Upvotes: 1

Views: 121

Answers (1)

Ahmed Laggoun
Ahmed Laggoun

Reputation: 191

well, I figured out the problem. It was because I forgot to upload .htaccess

Upvotes: 1

Related Questions