3

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.

  • Does your Laravel app route correctly, using "pretty" URLs and without index.php in the URL? – MrWhite Nov 29 '17 at 17:40
  • yes. Completely. Also, as mentioned, the first option (plain permalinks) is without index.php and works fine. – Avi Nov 29 '17 at 18:20
  • "The .htacess which resides within public->blog" - To clarify, you have spelt the .htaccess (2 c's) filename correctly? (I've since corrected that with my "edit" - but just realised that that would also explain your current problem!) – MrWhite Nov 29 '17 at 18:51
  • Yes, it's spelled correctly – Avi Nov 30 '17 at 6:26
  • Did you manage to resolve this? The fact that the admin panel is showing index.php in the example URL would seem to suggest that it has been unable to detect a suitable rewriting module (ie. mod_rewrite)? "the first option (plain permalinks) is without index.php and works fine" - Incidentally, that wouldn't need index.php anyway, even without mod_rewrite (providing the DirectoryIndex is set correctly). – MrWhite Dec 18 '17 at 16:35
-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...

  • Could you expand on the solution you found? – Burgi Jan 15 '18 at 12:06
  • I basically explained all there is to explain in the answer. When I uploaded the site to a live server and changed the permalinks, it worked just fine. Just like any other Wordpress site. – Avi Jan 17 '18 at 6:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.