Laravel and WordPress Integration – Installation

[PHP] Checkout what happens when world best CMS meets with the most popular MVC framework. It is a series of the tutorial where you can learn how to integrate WordPress and Laravel.

Laravel is one of the highly used, open-source modern web application frameworks to designs customized web applications quickly and easily. Developers prefer Laravel over to other frameworks because of the performance, features, scalability it offers, and on the other hand, WordPress is one of the most popular open source content management applications to develop Blog, Forum, and news feed, because of it vertical features and available plugin bank.
So today we thought why not get our hands dirty with this two together, and help our readers to give good head-start. In this series, we will be explaining how to install WordPress inside a Laravel application and get the WordPress post into Laravel.

Assuming we have a Laravel website running on and its physical path is /public_html/. Now we want to create a Blog using WordPress as, so we need to install WordPress in /public_html/blog/. Upload all the WordPress files in /blog/ directory. Now we have have edit the .htaccess of both the application so that Laravel should escep blog request for WordPress to process it.

.htaccess for Laravel

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews

    RewriteEngine On
    RewriteCond $1 !^(blog) #<—- Add this line
    # Redirect Trailing Slashes If Not A Folder…
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller…
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

.htaccess for WordPress

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/ #<– this line is modified.
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L] #<– this line is modified.
# END WordPress

Now we can directly access to install WordPress and set the permalink structure to Post name or any other beautiful URL structure.

In Next tutorial we’ll be learning as how to access WordPress post in Laravel.

Default image

Raunak Gupta

I'm an expert Laravel, WooCommerce, WordPress theme and plugin developer, over the time I have developed several sites and applications. I like to help the upcoming developer, So I share my experience through this blog.

Articles: 20

Leave a Reply