WordPress on a subdirectory of Laravel – WordPress pretty permalinks inner page shows laravel

I read lots of discussions about this and found no solution. I have a Laravel web app and added a WordPress site in a subdirectory. This is what my .htaccess looks like within the public folder:

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

RewriteEngine On
RewriteCond $1 !^(blog)


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

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

The .htaccess which resides within public->blog looks like this:

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

# END WordPress

Here’s the problem:

If I use the plain permalinks, everything works fine. If I use any other type of permalink it adds index.php to the URL and shows me the Laravel app.
The permalinks adds the index.php in the permalinks page:
enter image description here

The funny thing is, if I choose the post name permalink with the %postname% in it, the URL is:

http://localhost:8000/blog/postname/

and I see the laravel app, but the same URL with the admin (http://localhost:8000/blog/wp-admin/) or any other admin pages, works fine.

I really don’t want to have to use ugly permalinks here.

Is there a solution?

FYI – as you can see on the screenshot, the site is currently on localhost using XAMPP.

1 Answer
1

I accidentally found a solution.
I was using a local XAMPP installation and there was no way around it.
Though when I uploaded the site to a live server it worked fine.
I hope this helps someone in the future.
I’ve seen a lot of people with the same issue but never saw a solution…

Leave a Comment