使用 Cpanel cakephp 在新应用程序目录中设置子域

发布于 2024-11-06 21:20:40 字数 176 浏览 1 评论 0原文

我有工作domain.kz与cakephp(Cpanel托管)
www/应用
www/蛋糕
www/index.php

如何将 admin.domain.kz 设置为 (app2)

www/app
www/app2
www/蛋糕
www/index.php

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼泪淡了忧伤 2024-11-13 21:20:40

你想要的方式——将会非常困难;您必须在多个位置更改多个文件/文件夹路径。相反,为什么不尝试创建一个 admin 文件夹,其中包含用于管理的完整 cakephp 应用程序。

因此,最终的文件夹结构将如下所示:

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

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

然后,您必须将子域 (admin.domain.kz) 指向 /www/admin

现在假设您已正确配置域和子域,如果您尝试浏览您的域,它不会出现任何问题,但如果您尝试访问您的子域,则会出现 500 错误。不用担心。这是预料之中的。

主 .htaccess 文件强制由主 Webroot (www/app/webroot) 文件夹提供服务的所有请求。您必须像这样更改您的主 .htaccess 文件 (www/.htaccess):

<IfModule mod_rewrite.c>
    RewriteEngine on

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

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

请注意,我添加了两行,告诉您如果您尝试访问您的子域,请停止重写;否则照常重写。干杯!!!

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!!!

冷情妓 2024-11-13 21:20:40

如果蛋糕应用程序完全独立,但共享一个蛋糕库,那么以下方法可能有效:

一旦为 admin.domain.kz 设置了 DNS,您就可以使用 cPanel 的“Addon Domain”功能。 可以在此处找到说明

将插件域的文档根目录设置为 www/app2 文件夹。

然后只需确保 www/app2/webroot/index.php 中的 CAKE_CORE_INCLUDE_PATH 指向 ../../../cake

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文