English 中文(简体)
Kohana 3.2 鲁居问题和小问题
原标题:Kohana 3.2 Routing and subdomains problem

www.panel.example.com和www.example.com。

我的boot子陷阱:

<?php 
Kohana::init(array(
     base_url    =>  / ,
         index_file  => FALSE,
));

Route::set( panel ,  (<controller>(/<action>(/<id>))) , array( subdomain  =>  panel ))
    ->defaults(array(
         directory   =>  panel ,
         controller  =>  panel ,
         action      =>  index ,
         subdomain   =>  panel ,
    ));
Route::set( default ,  (<controller>(/<action>(/<id>))) )
    ->defaults(array(
         controller  =>  home ,
         action      =>  index ,
    ));
?>

当我撰写文章时,浏览器:www.panel.example.com 我有错误:

HTTP_Exception_404 [ 404 ]: The requested URL / was not found on this server.

我的结构:

申请/分类/控制器(域名控制器)

申请/职位/管理人员/小组(子公司控制员)

如何适当做到这一点?

问题回答

处理路线上的子宫未建。 因此,我的建议来自搜索因特网:

这样做的一个途径是从<代码>中获取分流。 SERVER 全球:

list($subdomain) = explode( . , $_SERVER[ SERVER_NAME ], 2);

之后,根据该次主要原则在路线上打上控制器或目录:

Route::set( panel ,  (<controller>(/<action>(/<id>))) )
  ->defaults(array(
     directory   => $subdomain,
     controller  =>  panel ,
     action      =>  index ,
  ));

Or use lambda/questbackways for more tempdomain:

答案基于对不同小域使用不同的模板:kohana v3:使用不同小域的模板

我使用该守则来检查是否需要确定次主要路线。

//Set an array with subdomains and Configs
$arrDomainsDirectories = array(
     services =>array(
         subdomain => services ,
         directory => Services ,
         controller  =>  Home ,
         action      =>  index 
    ),
     default =>array(
         subdomain =>NULL,
         directory =>  ,
         controller  =>  Home ,
         action      =>  index 
    )
);

//Config Route based on SERVER_NAME
$subdomain = explode( . , $_SERVER[ SERVER_NAME ], 2);

//If Not Subdomain set Default
if(count($subdomain) <= 1){
    $subdomain =  default ;
} else {
    $subdomain = $subdomain[0];
}

$routeConfig = $arrDomainsDirectories[$subdomain];

Route::set( default ,  (<controller>(/<action>(/<id>))) , array( subdomain =>$routeConfig[ subdomain ]))
    ->defaults(array(
         directory  => $routeConfig[ directory ],
         controller  => $routeConfig[ controller ],
         action      => $routeConfig[ action ]
    ));




相关问题
Rails: Proxy Pass?

I ve got a web-app that I want to migrate to Rails, which is currently just plain HTML with an Apache proxy to another server, running a custom database/webserver that serves the site s dynamic ...

MVC routing is not handling one of my directories

I m using ASP.NET MVC with IIS 7.0. I ve got 404 errors hooked up fine through my Application_Error override. In addition to "Controllers", "Models", "Helpers" etc. I have a directory called Files ...

Ruby on Rails conditional routing

I have a site listing many jobs, but I also want each account to be able to access its jobs in one place. Thus, I am using these routes: map.resources :jobs map.resource :account, :has_many => :...

Clean URL s using OpenCart s router class

How do you write clean URL s in OpenCart using their built in Router class? Here is my .htaccess file: RewriteEngine On RewriteRule ^(system) - [F,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{...

subdomain routing to multiple controller issue

I have a site: www.mydomain.com where we have administrative controls hidden away from normal customer view. I would like to only access the administrative features under a subdomain such as admin....

Can controller names in RESTful routes be optional?

With a standard map.resource routing mechanics and several nested resources the resultant routes are unnecessarily long. Consider the following route: site.org/users/pavelshved/blogs/blogging-horror/...

Help with rails routes

Im having a little trouble setting up routes. I have a users controller/model/views set up restfully so users is set up to be a resource in my routes. I want to change that to be usuarios ...

热门标签