如何使里面的其他CakePHP的制作安装新的子文件夹CakePHP安装工作 [英] How to make new cakephp installation work inside subfolder of other cakephp installtion

查看:98
本文介绍了如何使里面的其他CakePHP的制作安装新的子文件夹CakePHP安装工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个CakePHP安装在根文件夹说caketest.com 我想再跑CakePHP安装在一个子文件夹的子域说subdomain.caketest.com

I have a cakephp installation in root Folder say caketest.com I want run another cakephp installation in a sub folder with a sub-domain say subdomain.caketest.com

问题我面临的是,当​​我访问subdomain.caketest.com然后caketest.com的所有控制器都覆盖subdomain.caketest.com的控制器 可以说,外部蛋糕应用程序控制器正在执行的内心,而不是(但你知道我正在网址内饼)

Problem I am facing is when I access subdomain.caketest.com then all the controllers of caketest.com are overriding controllers of subdomain.caketest.com lets say app controller of outer cake is executing instead of inner (but you know I am running URL for inner cake)

因此​​,要克服这个我试过给改写基地内cakehphp .htacess

So to overcome this I tried giving rewrite base to inner cakehphp .htacess

我的目录结构

 public_html
  app
     webroot
     controllers
  ...and all cakephp folders
     index.php -of cake-
     .htaccess

  newyork -folder that contains another cakephp project 
            all cakephp folders and files

我在.htaccess尝试这个newyork的文件夹中,并得到内部服务器错误

I tried this in .htaccess inside newyork folder and get internal server error

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

谢谢 Surinder

Thanks Surinder

推荐答案

在我的网站,我运行CakePHP的,我有以下的目录结构:

On my website that I run CakePHP, I have the following directory structure:

public_html
   webroot
   controllers
   ...and all cakephp folders
   index.php -of cake-
   .htaccess
   Hosts -folder at which subdomains folders-
       dir -folder that contains another cakephp project called dir-
            all cakephp folders and files

我的主域运行CakePHP的应用程序,并dir.mydomain.com运行另一个CakePHP的应用程序。

My primary domain runs Cakephp app, and dir.mydomain.com runs another CakePHP app.

以下是的public_html中的.htaccess

The following is the .htaccess in public_html

# Turn off the ETags
Header unset ETag
FileETag None

# Turn off the Last Modified header except for html docs
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|mp3)$">
Header unset Last-Modified
</FilesMatch>
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf|mp3)$">
Header set Expires "Thu, 15 Jan 2015 20:00:00 GMT"
</FilesMatch>
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf|mp3)$">
   Header set Cache-Control "max-age=31449600"
 </FilesMatch>


# Use PHP5.3 as default
AddHandler application/x-httpd-php54 .php
#Deny from mydomain.com/Host/
Redirect /Host/dir/ http://dir.mydomain.com/

<IfModule mod_rewrite.c>


#RewriteRule .* http://%{SERVER_NAME}%{REQUEST_URI} [R,L]
    RewriteEngine on
#RewriteCond %{HTTPS} =on
#RewriteBase /~username/

   RewriteRule    ^$    webroot/    [L]
   RewriteRule    (.*) webroot/$1    [L]
  </IfModule>    

AddType audio/mpeg mp3
AddType text/xml xml

以下是的public_html /根目录和的public_html /主机/ DIR

The following is .htaccess of public_html/webroot and public_html/Host/dir

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

以下是的public_html /主机/ DIR /根目录中的.htaccess

The following is .htaccess of public_html/Host/dir/webroot

Options -Multiviews -Indexes +SymLinksIfOwnerMatch
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
DirectorySlash Off
RewriteCond %{HTTP_HOST} !^dir.mydomain.com$ [NC]
RewriteRule ^(.*)$ http://dir.mydomain.com/$1 [L,R=301]

RewriteRule ^/?searches/index/(.*)$ /searches/$1 [R=301,L]
RewriteRule ^(.*)/page:1$ /$1 [R=301,L] 
RewriteRule ^(.*)\/(\?.*)?$ $1$2 [R=301,L]
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

</IfModule>
AddType audio/mpeg mp3
AddType text/xml xml

根据我的共享主机支持创建子域的交友方式。还余分离的CakePHP芯从应用程序的结构和在根目录/ index.php的定义如下:

By the way my shared hosting supports creating sub-domains from the Cpanel. Also I separate the CakePHP core from the application structure and defined in webroot/index.php as follows:

if (!defined('CAKE_CORE_INCLUDE_PATH')) {
        define('CAKE_CORE_INCLUDE_PATH', DS.'home2'.DS.'username'.DS.'libs'.DS.'cakephp');
    }

这篇关于如何使里面的其他CakePHP的制作安装新的子文件夹CakePHP安装工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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