Laravel + Inertia + Vue.js Duplicates App_URL into url

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company

Solving the Inertia URL Duplication Mystery: Laravel, Inertia, and Web Server Deployment

As a senior developer working with modern full-stack frameworks like Laravel, Inertia.js, and Vue.js, we often encounter subtle yet frustrating issues when moving an application from a local development environment to a production-like server setup. One common stumbling block involves URL routing, especially when switching between the Laravel Artisan server and a traditional web server like Apache or Nginx (via XAMPP).

This post addresses a specific problem: why running an Inertia/Vue application results in a duplicated URL path (e.g., /laravel/laravel/) when served by a web host, compared to the clean path provided by php artisan serve. We will dive into the root cause and provide robust solutions.

The Context: Artisan Serve vs. Web Server Deployment

The behavior you are observing is not an error within Inertia or Vue itself; it is almost entirely a consequence of how the web server (Apache in your case) handles the document root and URL rewriting, interacting with how Laravel structures its public files.

When you run php artisan serve, Laravel acts as the complete environment: it handles routing, file serving, and internal session management all within that single process. The URL is clean because the server is directly mapping the request to the correct application entry point (index.php).

When you deploy this structure to a standard web server (like XAMPP/Apache), the server needs specific configuration—usually in .htaccess files or the main server configuration—to correctly map /laravel/ to your Laravel application's public directory, preventing the framework's internal file structure from appearing directly in the URL.

Deconstructing the Duplication

Your observation highlights a mismatch between the application’s intended root path and the web server’s interpretation of the request path. The duplication occurs because the web server is literally serving files from a subdirectory (e.g., /laravel/laravel/) instead of mapping the base domain to your Laravel entry point (index.php).

The createInertiaApp method itself, which sets up the frontend mounting logic using Vue and Inertia, operates correctly within PHP’s routing context. The issue surfaces when the external HTTP layer tries to resolve that internal path into a public URL.

Solutions for Clean Routing

To achieve a clean URL like http://localhost/laravel, you need to configure your web server to act as a proper reverse proxy for Laravel, ensuring all requests are routed through the public directory.

1. Configure Apache .htaccess (The Common Fix)

For standard PHP deployments, the most common solution is ensuring the .htaccess file in your public directory correctly handles URL rewriting. This usually involves setting up mod_rewrite rules to strip the base path prefix if necessary, or ensure the root directory is properly defined.

Ensure your deployment structure respects Laravel conventions. When deploying a Laravel application, typically you point the web server root directly to the public folder of your project.

2. Using Proper Web Server Configuration (Best Practice)

If you are using Apache, review your Virtual Host configuration or the specific directory configuration for your site. You must ensure that the document root is set correctly and that any requests coming into /laravel/ are handled by Laravel's entry point (public/index.php). This setup ensures that Laravel handles all routing internally, and the web server simply passes the request to it without exposing internal file structure.

For comprehensive deployment strategies, understanding how frameworks like those promoted by Laravel handle public access is crucial. As you build complex applications, adhering to these structural principles will save countless hours of debugging later on.

3. Reviewing Entry Points

While your app.js code seems architecturally sound for Inertia, always double-check that the entry point being accessed by the web server is indeed the Laravel application's public interface. If you are using a framework like Laravel, ensuring all asset paths and route definitions correctly reference the public directory is foundational to successful deployment.

Conclusion

The duplication issue in your Inertia application stems from an environmental configuration problem—the interaction between the Laravel routing structure and the external web server's path resolution, not a flaw in the Vue/Inertia code itself. By shifting focus from the frontend logic to the backend server configuration (Apache/XAMPP setup), you can resolve this by correctly configuring URL rewriting rules. Always prioritize understanding how your chosen deployment environment interacts with the framework structure when moving beyond the convenience of artisan serve.