Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel与Wordpress博客(与WP API)_Wordpress_Laravel_.htaccess_Laravel 5 - Fatal编程技术网

Laravel与Wordpress博客(与WP API)

Laravel与Wordpress博客(与WP API),wordpress,laravel,.htaccess,laravel-5,Wordpress,Laravel,.htaccess,Laravel 5,我的项目结构 /root_dir /app /bootstrap ... /public index.php .htaccess /wp #wordpress installation here /wp-admin /wp-content /wp-includes index.php .htaccess ... 所以,我想要完成的是有一个带有视图、API等的

我的项目结构

/root_dir
  /app
  /bootstrap
  ...
  /public
    index.php
      .htaccess
    /wp            #wordpress installation here
      /wp-admin
      /wp-content
      /wp-includes
      index.php
      .htaccess
      ...
所以,我想要完成的是有一个带有视图、API等的Laravel项目

我只需要一个route domain.com/blog就可以使用wordpress,在这里我会有一个单独的默认WP blog,它不会以任何方式与我的Laravel应用程序集成或交互

My/public/.htaccess

而my/public/blog/.htaccess是默认值

它就像一个符咒

我的劳拉路线很好。。。API路由-好。。。WP博客-太棒了

但是

现在我想调用wpapi,例如domain.com/blog/WP-json/WP/v2/posts

我所看到的是拉威尔的未找到页面

请帮忙

我有一种强烈的感觉,它可以解决。HTACE的'魔术',但不幸的是,我在这方面的noob

p.S.在这里发现了一个类似的问题
但我需要相反的解决方案

您可以代理将地址传递到其他地址, 例如,使用nginx:

server {
    listen  80;
    server_name blog.example.com;

    location / {
        root /var/www/wordpress;
        try_files $uri /index.html;
    }

 }





server {
    listen  80;
    server_name example.com www.example.com;

    location / {
        root /var/www/laravel;
        try_files $uri /index.html;
    }


    location /blog/ {

       proxy_pass http://blog.example.com/;
    }
 }
这是一种简单且干净的方法,而且您不需要更改哪怕一行代码就可以让laravel和wordpress彼此放在一边。

天哪

解决方案是导航到dashboard/settings/permalinks并将选项从“普通”更改为任何其他

在这里找到了答案

您需要使用相当长的永久链接来访问/wp json/。如果您没有,您可以使用?rest\u route=/来获取索引,并使用?rest\u route=/wp/v2/POST,例如针对特定路由


在Laravel5.4的旁边有一个关于Wordpress的章节,为什么不使用Wordpress的子域呢?例如blog.example.com,这样您就可以为web服务器拥有单独的项目和单独的站点配置。@LeszekRepie是的,在那里写的所有内容都已经在我的应用程序中工作了。主要问题:我无法调用WP APIOp是因为使用了.htaccess文件,Nginx不支持这些文件,但您提供了Nginx配置。你的建议在OP的服务器上不起作用。如果我无法访问主机上的apache/nginx配置,该怎么办?有什么想法吗?检查mod您的服务器mod_proxy是否安装了以下命令:apache2ctl-M如果您有shell访问权限,如果您没有使用此php函数获取已安装模块的列表:apache_get_modules,如果已安装,请使用本教程@mhndev。您的答案很好,但如果我无法配置nginx,并且我没有sudo用户,则不会有帮助但我把你的答案投了更高的票,以防对别人有所帮助
server {
    listen  80;
    server_name blog.example.com;

    location / {
        root /var/www/wordpress;
        try_files $uri /index.html;
    }

 }





server {
    listen  80;
    server_name example.com www.example.com;

    location / {
        root /var/www/laravel;
        try_files $uri /index.html;
    }


    location /blog/ {

       proxy_pass http://blog.example.com/;
    }
 }