Routes configuration for subdomains to modules

12 views
Skip to first unread message

Jonah Fuller

unread,
Jun 26, 2017, 3:05:25 PM6/26/17
to ColdBox Platform
Hi,

Apologies in advance if this questions has been asked, I couldn't find it though in my searches.

I'm trying to set up my routes file so that subdomains for my URL point to custom modules in my modules_app folder. For example:

http://mysite.com/admin becomes http://admin.mysite.com

And handlers/actions are presented without the name of the module in the URL like:

http://mysite.com/dashboard/settings/edit becomes http://dashboard.mysite.com/settings/edit


Does anybody have some example code on how to achieve this?

Thanks in advance...

Jonah Fuller

unread,
Jun 26, 2017, 3:13:48 PM6/26/17
to ColdBox Platform
Forgot to add the version in the subject! sorry!

Jon Clausen

unread,
Jun 26, 2017, 3:16:29 PM6/26/17
to col...@googlegroups.com

Jonah,

 

The easiest way to do this by customizing the PathInfoProvider( event ) method in your config/Routes.cfm. 

 

Then you can detect the inbound subdomain and prepend the module assignment to the route string.

 

Example:

 

function PathInfoProvider(Event){

 

      var pathArray = listToArray( CGI.PATH_INFO, "/" );

           

      switch( CGI.SERVER_NAME ){

            case "my.sub.domain.com":{

                  arrayPrepend( pathArray, "myModuleEntryPoint" );

                  break;

            }

      }

 

      return arrayToList( pathArray, "/" );

 

}

 

HTH,

Jon

--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coldbox/77dd8d0d-e90f-4150-a613-ae6946790722%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages