网站优化

网站优化

Products

当前位置:首页 > 网站优化 >

Laravel和Wordpress前端

GG网络技术分享 2025-03-18 16:12 5


问题描述:

I am building a web app on Laravel, which involves logins by multiple user types etc.

I would like to use Wordpress backend and frontend for most the CMS related stuff. I want to Wordpress frontend, as it is easier to maintain for the client, and a lot of the site\'s user facing pages are content that can be from wordpress.

I want the site to show pages from wordpress, if the route is not being handled by Laravel.

http://webapp.com/ -> (Landing Page)from Wordpress

http://webapp.com/laravelRoute -> Laravel

http://webapp.com/some-post-url -> Wordpress.

How can I achieve this by letting Laravel and Wordpress play nice with routing?

I\'ve tried installing Wordpress in public/ folder. However it doesn\'t recognise Laravel routes, works like a general wordpress site.

图片转代码服务由CSDN问答提供

感谢您的意见,我们尽快改进~

功能建议

我正在Laravel上构建一个Web应用程序,它涉及多个用户类型等的登录。</ p>

我想在大多数CMS相关的东西中使用Wordpress后端和前端。 我想要Wordpress前端,因为它更容易为客户端维护,并且很多站点的用户面向页面都是可以来自wordpress的内容。 </ p>

我希望网站显示来自wordpress的页面,如果</ em>路由未由Laravel处理。 </ p>

http://webapp.com/ - &gt; 来自Wordpress的(目标网页)</ p>

http://webapp.com/laravelRoute</ a> - &gt; Laravel </ p>

http://webapp.com/some-post- 网址 - &gt; WordPress的。 </ p>

如何通过让Laravel和Wordpress在路由方面表现出色来实现这一目标? </ p>

我尝试在公共/文件夹中安装Wordpress。 但它不能识别Laravel路线,就像一般的wordpress网站一样。</ p>

</ div>

网友观点:

Here\'s how I was able to fix it.

http://example.com/ -> Laravel code

<laravel code root>/public/pages -> wordpress code

You should be able to access http://example.com/pages/ -> from the wordpress content.

You also need to configure nginx to handle Wordpress URL redirects:

        ...

location /pages/index.php(/.*)?$ {

fastcgi_split_path_info ^(/pages/index.php)(/.+)$;

fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_read_timeout 1000;

fastcgi_param PATH_INFO $fastcgi_path_info;

include fastcgi_params;

}

location /pages/ {

if (!-e $request_filename) {

rewrite ^.*$ /pages/index.php last;

}

try_files $uri $uri/ pages/index.php?args;

}

location / { ...

###

To merge both Laravel and Wordpress on the same level you have two options or maybe more.

The first option is to setup .htaccess rewrite rules and redirect all Laravel routes to a laravel-index.php file. You rename the Laravel app index.php file to that.

The second option is to disable the wordpress index.php file and instead use Laravel\'s. In laravel create a catch all route that call the Wordpress object. So with this method, all you have to do is create the Laravel routes and the rest will just fall through to Wordpress.

标签:

提交需求或反馈

Demand feedback