dongpu4141 2017-10-18 07:57
浏览 43
已采纳

Laravel和Wordpress前端

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.

  • 写回答

2条回答 默认 最新

  • duancenxie2233 2018-04-23 06:28
    关注

    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 / { ...
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 酬劳2w元求合作写文章
  • ¥15 在现有系统基础上增加功能
  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图