2015-01-06 3 views
1

루트에 cakephp 설치가 있습니다. caketest.com 하위 도메인에 다른 cakephp 설치를 실행하려면 subdomain.caketest.com이라고 말하십시오.다른 cakephp 설치의 하위 폴더에 새로운 cakephp 설치 작업을하는 방법

문제 나는 subdomain.caketest.com에 액세스하면 caketest.com의 모든 컨트롤러가 subdomain.caketest.com의 컨트롤러를 무시합니다. 외부 케이크의 app 컨트롤러가 내부 대신 실행되고 있다고 말할 수 있습니다. 내가 내부 케이크에 대한 URL을 실행 중임을 아십시오)

그래서 이것을 극복하기 위해 내부 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 

은 내가 CakePHP의 실행 내 웹 사이트에 수린

+0

플러그인을 사용해 보셨습니까? – SaidbakR

+0

아니요. htaccess로이 작업을 수행하고 싶습니다. 그 작업이 가능하다는 것을 알고 있습니다. 그냥 어떻게 .. 모르겠다. – Rahul

답변

0

을 newyork의 폴더 안에 htaccess로이 시도하고 내부 서버 오류

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

감사를 얻을 수있다 , 다음과 같은 디렉토리 구조를 가지고 있습니다 :

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 앱을 실행합니다.

다음으로 public_html에서의 .htaccess이다

# 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을 웹 루트 및/호스트되는 다음의 .htaccess /으로 public_html/호스트 DIR

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

은 IS 다음의 .htaccess/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 

그런데 내 공유 호스팅은 하위 디렉토리를 만드는 것을 지원합니다. Cpanel에서 오즈. 또한 CakePHP 코어를 애플리케이션 구조와 분리하고 다음과 같이 webroot/index.php에 정의했습니다.

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