Combining Laravel Routes with WordPress Content Management

I’m working on a project where I need to integrate Laravel with WordPress in a specific way. My Laravel application handles user authentication and multiple user roles, but I want WordPress to manage the content side of things.

The goal is to have WordPress serve as the fallback when Laravel doesn’t have a matching route. For example:

  • Main homepage should come from WordPress
  • Specific Laravel routes like /dashboard or /admin should be handled by Laravel
  • Any blog posts or content pages should default to WordPress

I tried putting WordPress files in the public directory, but this breaks Laravel’s routing system completely. The site just acts like a regular WordPress installation and ignores all my Laravel routes.

What’s the best approach to make these two systems work together for routing? I need Laravel to check for its routes first, then pass unmatched requests to WordPress.

Interesting setup! Why not use WordPress as a headless CMS? What made you pick this architecture instead of keeping everything separate? And how are you handling user auth between the two systems?

yeah, i went this route too, but i set up a reverse proxy. keep laravel as ur main app, run wp in a subdir like /wp/, then use nginx to route content requests, way cleaner then mixing em up.

In integrating Laravel with WordPress, the solution I found effective involves separating the WordPress installation from the Laravel public directory. Create a catch-all route in Laravel that directs requests to WordPress only when no matching Laravel route exists. This entails including WordPress’s wp-blog-header.php and ensuring relevant constants are defined. Additionally, keep in mind that managing different database connections is crucial—use the appropriate configurations from both wp-config.php and Laravel’s settings. Also, remember to configure WordPress’s .htaccess file to avoid conflicts with Laravel’s routing.