URL Rewrite create subdomain in cakephp

一曲冷凌霜 提交于 2019-12-05 02:37:14

You can leave your .htaccess as in the default cakephp/.htaccess cakephp/app/.htaccess cakephp/app/webroot/.htaccess

You will need the virtual host like now have pointing at your app.

What you really need to look at is the app/Config/routes.php

take a look at the line that says:

CakePlugin::routes();

So, before that moment you can do anything you need (with routes). Lets imagine a user johndoe has http://johndoe.yourapp.com/

Get the subdomain from the url, something like this:

array_shift((explode(".",'subdomain.my.com')));

using:

$_SERVER['HTTP_HOST']


Router::connect('/users/front_home', array('controller' => 'users', 'action' => 'front_home', $yourSubDomain));

Or just leave the router alone and detect the subdomain in your AppController, and use it anywhere in your app.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!