按照你的背景下,这个目录里面:/lib/Cake/Routing/Route
,创建文件SubdomainRoute.php
的内容:
class SubdomainRoute extends CakeRoute {
public function match($params) {
$subdomain = isset($params['subdomain']) ? $params['subdomain'] : null;
unset($params['subdomain']);
$path = parent::match($params);
if ($subdomain) {
$path = 'http://' . $subdomain . '.thechatfun.com' . $path;
}
return $path;
}
}
当创建你可以链接请执行以下操作使链接指向其他子域。
echo $this->Html->link(
'Profile',
array('subdomain' => 'profile', 'controller' => 'Users', 'action' => 'profile')
);
echo $this->Html->link(
'Chats',
array('subdomain' => 'chat', 'controller' => 'Chats', 'action' => 'index')
);
参考:http://book.cakephp.org/2.0/en/appendices/new-features-in-cakephp-2-0.html#routes-can-return-full-urls
我认为本教程对您有所帮助:http://book.cakephp.org/2.0/en/appendices/new-features-in-cakephp-2-0.html#routes-can-return-full -urls – 2014-11-23 04:24:39
检查它... http://stackoverflow.com/questions/6744733/how-to-create-sub-domains-using-cake-php – 2014-11-27 18:00:40