【问题标题】:.htaccess / mod_rewrite.c : CakePHP application in a subfolder where the root folder hosts a Wordpress installation.htaccess / mod_rewrite.c :CakePHP 应用程序位于根文件夹托管 Wordpress 安装的子文件夹中
【发布时间】:2013-06-20 08:33:44
【问题描述】:

我想将我的 CakePHP 应用从 localhost 部署到网络服务器,但我得到了Error 500

我的文件夹结构如下所示(注意:Cake-app 不在根目录中...)。 .htaccess-files (0) - (3) 是根据 this post [SO]: 的,因为这是一个 CakePHP&Wordpress 服务器,所以我尝试了 this advice here, too [SO]。 该应用程序显然位于CAKEAPP-文件夹中,其中一个子域cakeapp.mydomain.com 指向。

ROOT
├── .htaccess (0)
├── CAKEAPP
│   ├── .htaccess (1)
│   ├── app
│   │   ├── .htaccess (2)
│   │   ├── WEBROOT
│   │   │   ├── .htaccess (3)
├──{wordpress-files}

(0) .htaccess 在ROOT 文件夹中

    Action php /cgi-php52/php
AddHandler php52 .php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

php_value memory_limit "128M"

#BEGIN Image Upload HTTP Error Fix
<IfModule mod_security.c>
<Files async-upload.php>


</Files>
</IfModule>
<IfModule security_module>
<Files async-upload.php>


</Files>
</IfModule>
<IfModule security2_module>
<Files async-upload.php>


</Files>
</IfModule>
#END Image Upload HTTP Error Fix

(1) .htaccess 在CAKEAPP-文件夹中

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

(2) .htaccess 在ROOT/CAKEAPP/APP-文件夹中

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

(3) .htaccess 在ROOT/CAKEAPP/APP/WEBROOT-文件夹中

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /app/webroot
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

【问题讨论】:

  • │ │ ├── WEBROOT webroot,可能就是这样。原则上,您无需将蛋糕应用程序放入子文件夹中

标签: wordpress .htaccess cakephp mod-rewrite


【解决方案1】:

以下适用于mydomain.com/cakeapp

(0) .htaccess in ROOT FOLDER

#Action php /cgi-php52/php
#AddHandler php52 .php

# BEGIN WordPress
<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /
 RewriteRule ^cakeapp/(.*)$ /cakeapp/$1 [L,QSA]
 RewriteRule ^index\.php$ - [L]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule . /index.php [L]
</IfModule>
# END WordPress

(1) .htaccess 在CAKEAPP-文件夹中

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

(2) .htaccess 在ROOT/CAKEAPP/APP-文件夹中

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

(3) .htaccess 在ROOT/CAKEAPP/APP/WEBROOT-文件夹中

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /cakeapp
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

【讨论】:

    【解决方案2】:

    我有两个项目一个主项目运行良好,但现在我想在同一个域上运行另一个 cakephp 项目。

    所以你在编写本教程将帮助你在子域上运行 cakephp

    1. 首先您更改了 /httpdocs/ 上的 .htaccess 重写引擎开启 RewriteBase / RewriteRule ^$ cake_sub_project/app/webroot/ [L] RewriteRule (.*) cake_sub_project/app/webroot/$1 [L] 这两个新行需要添加到您的主 .htaccess 文件中。这里的“cake_sub_project”是子项目 RewriteRule ^$ cake_sub_project/app/webroot/ [L] RewriteRule (.*) cake_sub_project/app/webroot/$1 [L]

    现在转到您的子文件夹并确保您已更改以下目录中的 .htacces。

    cake_sub_project/ cake_sub_project/应用程序 cake_sub_project/webroot 2. 需要从/httpdocs/cake_sub_project 编辑.htaccess 如下
    重写引擎开启 RewriteBase /cake_sub_project/ RewriteRule ^$ app/webroot/ [L] RewriteRule (.*) app/webroot/$1 [L]
    1. 需要从 /httpdocs/cake_sub_project/app 编辑 .htaccess 如下

      重写引擎开启 RewriteBase /cake_sub_project/app/ 重写规则 ^$ webroot/ [L] RewriteRule (.*) webroot/$1 [L]
    2. 需要从 /httpdocs/cake_sub_project/app/webroot 编辑 .htaccess 如下

      重写引擎开启 RewriteBase /cake_sub_project/app/webroot/ RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-07-19
      • 2016-05-27
      • 1970-01-01
      • 2018-02-26
      • 2017-07-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多