最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

urls - Wordpress on a subdirectory of Laravel - Wordpress pretty permalinks inner page shows laravel

programmeradmin0浏览0评论

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:

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.

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:

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.

Share Improve this question edited Nov 29, 2017 at 19:50 MrWhite 3,8911 gold badge20 silver badges23 bronze badges asked Nov 29, 2017 at 16:39 AviAvi 1594 bronze badges 6
  • Does your Laravel app route correctly, using "pretty" URLs and without index.php in the URL? – MrWhite Commented Nov 29, 2017 at 17:40
  • yes. Completely. Also, as mentioned, the first option (plain permalinks) is without index.php and works fine. – Avi Commented Nov 29, 2017 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 Commented Nov 29, 2017 at 18:51
  • Yes, it's spelled correctly – Avi Commented Nov 30, 2017 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 Commented Dec 18, 2017 at 16:35
 |  Show 1 more comment

1 Answer 1

Reset to default 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...

发布评论

评论列表(0)

  1. 暂无评论