I've been desperately trying to figure out a good method to use
dynamic subdomains and I am so close!

Here is what I have going on:

1) My app_controller checks the subdomain against the database and
makes sure it's valid. If not, it redirect - works great!

2) I put the following hack inside routes.php:

$subdomain = substr( env("HTTP_HOST"), 0, strpos(env("HTTP_HOST"),
".") );

    if(strlen($subdomain) > 0 && $subdomain != "www")
    {
        Router::connect('/:action/*',
array('controller'=>'contests', 'action'=>'index'));
    }

So basically, if the subdomain isn't www (and it's valid per
app_controller), it uses the contests controller. So,
http://validsubdomain.domain.com/upload is contests/upload - works
great!

3) The ONLY piece left is to make http://validsubdomain.domain.com
(with no action) default to 'index' or 'default' action.

I tried this:

$subdomain = substr( env("HTTP_HOST"), 0, strpos(env("HTTP_HOST"),
".") );

    if(strlen($subdomain) > 0 && $subdomain != "www")
    {
        Router::connect('/*',
array('controller'=>'contests', 'action'=>'index'));
        Router::connect('/:action/*',
array('controller'=>'contests', 'action'=>'index'));
    }

And basically every variable of that (/  /* , action = index, default,
etc.) and it just loads the pages controller.

To recap, currently:

http://validsubdomain.domain.com = pages/display
http://validsubdomain.domain.com/upload = contests/upload

Anyone who tells me how to get http://validsubdomain.domain.com to go
to contests/default gets a big cookie!!!!!!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to