Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

valentin_vranic's avatar

Livewire not found, under subdirectory

I've installed new laravel 11 and livewire 3.5. Under http://my_url/dashboard in apache I redirect to var/www/html/my_app . Everything is working fine, except livewire, in console I'm getting this error: http://my_url/livewire/livewire.js?id=cc800bf4 net::ERR_ABORTED 404 (Not Found)

I've tried with:

Livewire::setScriptRoute(function ($handle) {
    return Route::get('/dashboard/livewire/livewire.js', $handle);
});

with the same results.

What am I missing?

0 likes
1 reply
LaryAI's avatar
Level 58

It looks like the issue you're encountering is related to the URL structure and how Livewire's assets are being served. When you have your Laravel application in a subdirectory, you need to ensure that Livewire's assets are correctly referenced.

Here are the steps to resolve this issue:

  1. Update the APP_URL in your .env file: Make sure your APP_URL in the .env file reflects the subdirectory structure. For example:

    APP_URL=http://my_url/dashboard
    
  2. Publish Livewire's configuration file: If you haven't already, publish the Livewire configuration file using the following command:

    php artisan livewire:publish --config
    
  3. Update the Livewire configuration: Open the config/livewire.php file and update the asset_url to include your subdirectory. For example:

    'asset_url' => env('APP_URL') . '/livewire',
    
  4. Ensure your web server configuration is correct: Make sure your Apache configuration correctly points to the subdirectory. Your Apache configuration should look something like this:

    <VirtualHost *:80>
        ServerName my_url
        DocumentRoot /var/www/html/my_app/public
    
        <Directory /var/www/html/my_app>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>
    </VirtualHost>
    
  5. Clear caches: Clear any cached configuration and routes to ensure your changes take effect:

    php artisan config:clear
    php artisan route:clear
    php artisan view:clear
    
  6. Check your routes: Ensure that your routes are correctly set up to handle Livewire requests. You shouldn't need to manually set the script route as Livewire handles this internally.

After making these changes, your Livewire assets should be correctly referenced, and the 404 error should be resolved.

Here's a summary of the key configuration changes:

.env

APP_URL=http://my_url/dashboard

config/livewire.php

'asset_url' => env('APP_URL') . '/livewire',

Apache Configuration

<VirtualHost *:80>
    ServerName my_url
    DocumentRoot /var/www/html/my_app/public

    <Directory /var/www/html/my_app>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

By following these steps, you should be able to resolve the issue with Livewire not being found under the subdirectory.

Please or to participate in this conversation.