htaccess rewrite rules for Laravel / Lumen and WordPress

Do you want to get Lumen or Laravel to play nice with WordPress?

I did too…

Below is how I got them to work together with just a few lines in the .htaccess files…

NOTE: The code below is assuming you are installing WordPress in a blog sub-directory for example http://yourdomain.com/blog and have lumen or laravel installed in the root directory.

Modify Laravel or Lumen .htaccess

Your lumen or laravel .htaccess file should contain this one additional line… I know right? Just one line…


    
        #Options -MultiViews
    

    RewriteEngine On

    RewriteCond %{REQUEST_URI} !^/blog/ # <=== NEW LINE!!!!

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]


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

Modify WordPress .htaccess

Your WordPress .htaccess file should contain the following two lines, like this…


# BEGIN WordPress

RewriteEngine On
RewriteBase /blog/   # <==== CHANGED LINE!!
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
 
RewriteRule . /blog/index.php [L] # <==== CHANGED LINE!!!


# END WordPress

WooHoo!

That’s about it, I was able to setup FeedSumo.com with a WordPress install in a /blog sub-directory, FeedSumo is powered by Lumen.

If you have any questions or suggestions, please post them below!

what do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.