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条)

报告相同问题?

悬赏问题

  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果