Laravel app inside Wordpress website run on app folder and not in app/public folder?

37 Views Asked by At

I have a wordpress website in which I want to use a Laravel app in a subfolder

Like this:

But I only managed to run it like this:

Whatever I do, I keep receiving http 404 when trying to access any of my views except when trying on the public folder.

What can I do to make laravel start routing from the root laravell app (/app, like normally is when it's only laravel) and not from the /app/public folder?

I have tried changing RewriteBase but it didn't worked.

1

There are 1 best solutions below

1
Alireza Karimpoor On

Better to do this using a subdomain, but anyway

  • Create a folder with the desired name inside the cPanel public_html folder, for example, Laravel
  • Put the contents of the public folder related to Laravel into this folder
  • Create another folder with the name app or any other desired name in cPanel and before the Public_html folder and put the complete content of Laravel except the Public folder into this folder.

enter image description here

  • Now go to the public_html folder and then enter the Laravel folder and open the index.php file and apply the following changes and save the file:

require __DIR__.'/../app/vendor/autoload.php';
$maintenance = __DIR__.'/../app/storage/framework/maintenance.php';
$app = require_once __DIR__.'/../app/bootstrap/app.php';

Update the .env file according to the database information and then open the address of your Laravel program