开发者

Setup subdomain in new app directory with Cpanel cakephp

I have working domain.kz with cakephp (Cpanel hosting)

www/app

www/cake

www/index.php

how can i setup admin.domain.kz to (app2)

www/app

www/app2

www/cake

www/index.php 开发者_开发百科


The way you want it - will be very difficult; you'll have to change several file/folder paths in several places. Instead, why don't you try to create an admin folder where you've the full cakephp application for admin.

So the resulting folder structure would be like this:

(domain.kz)
www/app
www/cake
www/index.php

(admin.domain.kz)
www/admin/app
www/admin/cake
www/admin/index.php

Then you'll have to point your subdomain (admin.domain.kz) to /www/admin.

Now assuming that you've configured your domain and subdomain correctly, if you try to browse your domain, it'll work with no issues but if you try to access your subdomain, it'll give you a 500 error. DON'T WORRY. It is expected.

The primary .htaccess file is forcing all requests served by primary webroot (www/app/webroot) folder. You'll have to change your primary .htaccess file (www/.htaccess) like this:

<IfModule mod_rewrite.c>
    RewriteEngine on

    RewriteCond %{HTTP_HOST} ^admin\.domain\.kz$ [NC]
    RewriteRule ^ - [L]

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

Notice that, I've added two lines which tells that if you're trying to access your subdomain, stop rewriting; otherwise rewrite as usual. Cheers!!!


If the cake apps are totally separate but share a cake library then the following might work:

You could use cPanel's 'Addon Domain' feature, once the DNS has been set up for admin.domain.kz. Instructions can be found here.

Set the document root of the addon domain to the www/app2 folder.

Then just make sure that CAKE_CORE_INCLUDE_PATH in www/app2/webroot/index.php points to ../../../cake

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜