Welcome Guest, Not a member yet? Register   Sign In
hao can i routing subdomain?
#1

hao can i routing subdomain?  
Reply
#2

(This post was last modified: 09-22-2015, 04:08 AM by Muzikant.)

Not from CodeIgniter. You can route only controllers of the domain/subdomain, where your system is installed or from where it is accessed.

Read URI Routing section in the documentation.

But maybe with a .htaccess file or by changing the server configuration it could be achievable, but it is just a hypotesis. Tell us, if you will find a solution.
Reply
#3

Some things are simpler than they seem ...

Code:
// application/config/routes.php
switch ($_SERVER['HTTP_HOST'])
{
    case 'sub.domain.tld':
        // your sub.domain.tld routes here
        break;
    case 'default.domain.tld':
    default:
        // your default domain routes here
        break;
}
Reply
#4

(09-23-2015, 05:00 AM)Narf Wrote: Some things are simpler than they seem ...


Code:
// application/config/routes.php
switch ($_SERVER['HTTP_HOST'])
{
   case 'sub.domain.tld':
       // your sub.domain.tld routes here
       break;
   case 'default.domain.tld':
   default:
       // your default domain routes here
       break;
}

Wouldn't this only work if your subdomain is pointing to the same root directory as your main domain?
Reply
#5

(09-23-2015, 05:13 AM)Martin7483 Wrote:
(09-23-2015, 05:00 AM)Narf Wrote: Some things are simpler than they seem ...



Code:
// application/config/routes.php
switch ($_SERVER['HTTP_HOST'])
{
   case 'sub.domain.tld':
       // your sub.domain.tld routes here
       break;
   case 'default.domain.tld':
   default:
       // your default domain routes here
       break;
}

Wouldn't this only work if your subdomain is pointing to the same root directory as your main domain?

Yes, but how else do you expect to be able to have domain-based routing within CI?
Reply
#6

(09-23-2015, 05:19 AM)Narf Wrote:
(09-23-2015, 05:13 AM)Martin7483 Wrote:
(09-23-2015, 05:00 AM)Narf Wrote: Some things are simpler than they seem ...



Code:
// application/config/routes.php
switch ($_SERVER['HTTP_HOST'])
{
   case 'sub.domain.tld':
       // your sub.domain.tld routes here
       break;
   case 'default.domain.tld':
   default:
       // your default domain routes here
       break;
}

Wouldn't this only work if your subdomain is pointing to the same root directory as your main domain?

Yes, but how else do you expect to be able to have domain-based routing within CI?

I was asking because a subdomain by default points to it's own directory in the root of your hosting
Reply
#7

(09-23-2015, 05:24 AM)Martin7483 Wrote: I was asking because a subdomain by default points to it's own directory in the root of your hosting

This depends on your host, and in most cases it can be changed. You could also put a copy of the index.php file in each subdomain and modify each index.php file to point to the same directories for everything else, or you could setup separate application directories for each subdomain but share the system directory.
Reply
#8
Thumbs Up 

(09-23-2015, 05:00 AM)Narf Wrote: Some things are simpler than they seem ...


Code:
// application/config/routes.php
switch ($_SERVER['HTTP_HOST'])
{
   case 'sub.domain.tld':
       // your sub.domain.tld routes here
       break;
   case 'default.domain.tld':
   default:
       // your default domain routes here
       break;
}

this is a good one, but some controlller dosn't work 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB