如何创建一个子域在CakePHP中?创建一个、CakePHP

2023-09-02 00:44:45 作者:你是我写过最美的情书

CakePHP的版本2.5.5

CakePHP version-2.5.5

我的域名是 http://www.thechatfun.com

概况页链接 - http://www.thechatfun.com/users/profile

聊天页面的链接 - http://www.thechatfun.com/chats/index

Chat page link - http://www.thechatfun.com/chats/index

以上两种链接,我想看起来像 http://profile.thechatfun.com 的http://www.chat.thechatfun。 COM

Above two link i want to looks like http://profile.thechatfun.com and http://www.chat.thechatfun.com

我无法使子域在CakePHP的。

I am unable to make subdomain in the CakePHP.

请帮我

谢谢 ChatFun

Thanks ChatFun

推荐答案

只要你可以配置你的域名记录双方聊天和配置文件子域名指向你的服务器,那么你可以改变htaccess的文件在您的根目录文件夹并添加。

As long as you can configure your domain records to point both chat and profile subdomains to your server then you can change the htaccess file in your webroot folder and add..

    <IfModule mod_rewrite.c>
      #standard cake htaccess stuff
      ...

      RewriteCond %{HTTP_HOST} ^profile.thechatfun.com$ [NC]
      RewriteRule ^(.*)$ http://www.thechatfun.com/users/profile/$1 [R=301,L]

      RewriteCond %{HTTP_HOST} ^chat.thechatfun.com$ [NC]
      RewriteRule ^(.*)$ http://www.thechatfun.com/chats/index/$1 [R=301,L]

    </IfModule>

我有这样精确的要求,这对我的作品。

I have this exact requirement and this works for me.