Laravel和Wordpress在同一服务器/域上 [英] Laravel and Wordpress on same server/domain

查看:85
本文介绍了Laravel和Wordpress在同一服务器/域上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Laravel(5.1)项目中托管一个WordPress网站.我有以下结构(简化了部分)

I am trying to host a WordPress site inside a Laravel(5.1) project. I have the following structure (stripped down some)

├── app
├── config
├── public
│   ├── index.php
│   ├── wordpress -> ../wordpress
│   └── .htaccess
├── resources
├── storage
├── vendor
└── wordpress
    ├── index.php
    ├── wp-admin
    ├── wp-config.php
    ├── wp-includes
    └── .htaccess

vhost文档的根是公共的.

The vhost document root is public.

Wordpress应该捕获通过.htaccess掉落的所有内容.但例如/login应该转到laravel.当我的项目增长时,我打算添加更多规则来捕获对Laravel的请求.我在/public中有以下.htaccess文件:

The Wordpress should catch everything that falls through the .htaccess. But for example /login should go to laravel. When my project grows i intend to add more rules to catch requests for Laravel. I have the following .htaccess file in /public:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule "^/login" "index.php" [L]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule "^(.*)$" "wordpress/$1" [L]
</IfModule>

但是当我向/login发出请求时,我仍然以wordpress页面结束.这是日志的一部分:

But when i make the request to /login i still end up with the wordpress page. Here is a part of the log:

 add path info postfix: /var/www/public/login -> /var/www/public/login/
 strip per-dir prefix: /var/www/public/login/ -> login/
 applying pattern '^/login' to uri 'login/'
 add path info postfix: /var/www/public/login -> /var/www/public/login/
 strip per-dir prefix: /var/www/public/login/ -> login/
 applying pattern '^(.*)$' to uri 'login/'
 RewriteCond: input='/var/www/public/login' pattern='!-d' => matched
 RewriteCond: input='/var/www/public/login' pattern='!-f' => matched
 rewrite 'login/' -> 'wordpress/login/'
 add per-dir prefix: wordpress/login/ -> /var/www/public/wordpress/login/
 strip document_root prefix: /var/www/public/wordpress/login/ -> /wordpress/login/
 internal redirect with /wordpress/login/ [INTERNAL REDIRECT]

似乎重写不会在[L]标志处停止.

It seems like the rewriting does not stop at the [L] flag.

推荐答案

最终在ServerFault上问了同样的问题.在那里,我得到了答案.在此处链接以供参考:

Ended up asking the same question on ServerFault. There i got the answer. Linking it here for refference:

> https://serverfault.com/questions/739728/laravel-and -wordpress-on-same-server-domain

这篇关于Laravel和Wordpress在同一服务器/域上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆