【问题标题】:Installing Wordpress inside CakePHP 3在 CakePHP 3 中安装 Wordpress
【发布时间】:2017-08-10 23:54:33
【问题描述】:

我正在尝试在 CakePHP 3 中使用 Wordpress。我关注了 this,但它不起作用。两个问题:

  • 如果我尝试domain.com/wordpress/,我会陷入这个same issue500 internal server error
  • 如果我尝试domain.com/wordpress(不带斜杠),它会像cakePHP 请求一样处理,我会得到Error: WordpressController could not be found

我也尝试过使用 WP 的修改版 bedrock。但没有运气。

文件夹结构(带原WP):

www/
├─── cake/
│   ├─── webroot/
│   │    └── .htaccess
│   ├─── wordpress/
│   │    └── .htaccess
│   └── .htaccess
└── .htaccess

还有各种htaccess 文件:

www/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule (wordpress/.*) $1 [L] # adjust the regex to what you want.
    RewriteRule    ^$ cake/webroot/    [L]
    RewriteRule    (.*) cake/webroot/$1 [L]
</IfModule>

www/cake/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /cake/
    RewriteRule (.*) webroot/$1 [L]
</IfModule>

www/cake/webroot/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /cake/webroot/

    RewriteCond %{THE_REQUEST} \s/+cake/webroot/([^\s&]*) [NC]
    RewriteRule ^ /%1 [R=302,L]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

www/cake/wordpress/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /wordpress/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /wordpress/index.php [L]
</IfModule>

/var/log/error.log

[core:error] [pid 5506] [client xxx.xxx.xxx.xxx:55118] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

*LogLevel 已设置为调试。

【问题讨论】:

  • 查看www/error_log 并将您发现的内容粘贴到此处。
  • @EduardoEscobar 完成
  • 尝试提高跟踪日志级别以获取有关重写流程的详细信息:httpd.apache.org/docs/current/mod/mod_rewrite.html#logging
  • 我把调试改成trace3 并查看了日志。我不知道为什么,但是当我将所有内容都设置为/var/www/html/cake/ 时,apache 正在/var/www/html/ 中寻找wordpress 的directoty。上移一级后,它起作用了。

标签: wordpress .htaccess cakephp cakephp-3.0


【解决方案1】:

您的 www/cake/wordpress/.htaccess 应该是:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /cake/wordpress/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /cake/wordpress/index.php [L]
</IfModule>

编辑

好的,问题来了。 http://example.com/ 指向 www/ 目录。你希望 http://example.com/wordpress/ 指向 www/cake/wordpress。您需要充分利用 www/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^/wordpress(/.*)?$ /cake/wordpress$1 [L,QSA]
    RewriteRule    ^$ cake/webroot/    [L]
    RewriteRule    (.*) cake/webroot/$1 [L]
</IfModule>

【讨论】:

  • 不走运。日志中仍然出现 500 错误和相同的内容。
  • 你的 PHP 版本是多少?日志条目的时间戳是否与实际时间相符?
  • 你能在 www/cake/wordpress/ 中运行任何其他 php 脚本吗,比如 test.php 里面有 phpinfo(); 函数?
  • 现在(带和不带斜杠)都找不到控制器。
  • 我已接受您的回答。 .htaccess 是正确的。它不起作用,因为文件夹位于错误的位置。
猜你喜欢
  • 2015-11-27
  • 1970-01-01
  • 1970-01-01
  • 2015-08-11
  • 2014-12-22
  • 2018-02-21
  • 2014-05-01
  • 2012-10-08
  • 1970-01-01
相关资源
最近更新 更多